ALSA: jack: don't report input event for phantom jack
authorJie Yang <yang.jie@intel.com>
Thu, 30 Apr 2015 12:22:46 +0000 (20:22 +0800)
committerTakashi Iwai <tiwai@suse.de>
Thu, 30 Apr 2015 13:21:35 +0000 (15:21 +0200)
There is no input_dev for phantom jack, we should not report
input event for it, otherwise, NULL pointer dereference error
will occur.

Fixes: 2ba2dfa1fcc7 ('ALSA: hda - Update to use the new jack kctls method')
Signed-off-by: Jie Yang <yang.jie@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/jack.c

index e8b51f5..0dbd618 100644 (file)
@@ -339,6 +339,13 @@ void snd_jack_report(struct snd_jack *jack, int status)
        if (!jack)
                return;
 
+       list_for_each_entry(jack_kctl, &jack->kctl_list, list)
+               snd_kctl_jack_report(jack->card, jack_kctl->kctl,
+                                           status & jack_kctl->mask_bits);
+
+       if (!jack->input_dev)
+               return;
+
        for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
                int testbit = SND_JACK_BTN_0 >> i;
 
@@ -357,10 +364,6 @@ void snd_jack_report(struct snd_jack *jack, int status)
 
        input_sync(jack->input_dev);
 
-       list_for_each_entry(jack_kctl, &jack->kctl_list, list)
-               snd_kctl_jack_report(jack->card, jack_kctl->kctl,
-                                           status & jack_kctl->mask_bits);
-
 }
 EXPORT_SYMBOL(snd_jack_report);