diff options
author | Mengdong Lin <mengdong.lin@intel.com> | 2013-03-07 14:11:05 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-03-07 09:14:03 +0100 |
commit | 4c7a548a70a44269266858f65c3b5fc9c3ace057 (patch) | |
tree | 826810f4e37ffe5a315345842a399ad1135b36d6 /sound/pci | |
parent | 25336e8ae2d2fa64c9c4cc2c9c28f641134c9fa9 (diff) | |
download | blackbird-op-linux-4c7a548a70a44269266858f65c3b5fc9c3ace057.tar.gz blackbird-op-linux-4c7a548a70a44269266858f65c3b5fc9c3ace057.zip |
ALSA: hda - check NULL pointer when creating SPDIF PCM switch
If the new control cannot be created, this function will return to avoid
snd_hda_ctl_add dereferencing a NULL control pointer.
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 3dc656688c08..97c68dd24ef5 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3433,11 +3433,16 @@ static struct snd_kcontrol_new spdif_share_sw = { int snd_hda_create_spdif_share_sw(struct hda_codec *codec, struct hda_multi_out *mout) { + struct snd_kcontrol *kctl; + if (!mout->dig_out_nid) return 0; + + kctl = snd_ctl_new1(&spdif_share_sw, mout); + if (!kctl) + return -ENOMEM; /* ATTENTION: here mout is passed as private_data, instead of codec */ - return snd_hda_ctl_add(codec, mout->dig_out_nid, - snd_ctl_new1(&spdif_share_sw, mout)); + return snd_hda_ctl_add(codec, mout->dig_out_nid, kctl); } EXPORT_SYMBOL_HDA(snd_hda_create_spdif_share_sw); |