ALSA: hda - Fix NULL dereference in snd_hda_gen_build_controls()
authorTakashi Iwai <tiwai@suse.de>
Wed, 19 Dec 2012 14:15:10 +0000 (15:15 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sat, 12 Jan 2013 07:30:59 +0000 (08:30 +0100)
When no controls are assigned in the parser (e.g. no analog path),
spec->kctls.list is still NULL.  We need to check it before passing to
snd_hda_add_new_ctls().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_generic.c

index e512cab..364ec06 100644 (file)
@@ -2906,9 +2906,11 @@ int snd_hda_gen_build_controls(struct hda_codec *codec)
        struct hda_gen_spec *spec = codec->spec;
        int err;
 
-       err = snd_hda_add_new_ctls(codec, spec->kctls.list);
-       if (err < 0)
-               return err;
+       if (spec->kctls.used) {
+               err = snd_hda_add_new_ctls(codec, spec->kctls.list);
+               if (err < 0)
+                       return err;
+       }
 
        if (spec->multiout.dig_out_nid) {
                err = snd_hda_create_dig_out_ctls(codec,