From cfc7c9d307b6a3557e333f960218d344d3a70ce7 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 11 Nov 2011 17:53:03 +0100
Subject: [PATCH] ALSA: hda/jack - Fix NULL-dereference at probing
Git-commit: cfc7c9d307b6a3557e333f960218d344d3a70ce7
Patch-mainline: 3.3-rc1
References: FATE#313695

At probing time, the elements that aren't assigned to kctl or jack may
be called.  Need proper NULL-checks.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 sound/pci/hda/hda_jack.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/sound/pci/hda/hda_jack.c
+++ b/sound/pci/hda/hda_jack.c
@@ -194,6 +194,8 @@ void snd_hda_jack_report_sync(struct hda
 	for (i = 0; i < codec->jacktbl.used; i++, jack++)
 		if (jack->nid) {
 			jack_detect_update(codec, jack);
+			if (!jack->kctl)
+				continue;
 			state = get_jack_plug_state(jack->pin_sense);
 			snd_kctl_jack_report(codec->bus->card, jack->kctl, state);
 		}
@@ -356,7 +358,7 @@ void snd_hda_input_jack_report(struct hd
 	unsigned int present;
 	int type;
 
-	if (!jack)
+	if (!jack || !jack->jack)
 		return;
 
 	present = snd_hda_jack_detect(codec, nid);
