From 36502d020030665bcfc558767cbb0ddf87b9892f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 19 Dec 2012 15:15:10 +0100 Subject: [PATCH] ALSA: hda - Fix NULL dereference in snd_hda_gen_build_controls() 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 --- sound/pci/hda/hda_generic.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index e512cab22e91..364ec06071ae 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -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, -- GitLab