Commit 4c7a548a authored by Mengdong Lin's avatar Mengdong Lin Committed by Takashi Iwai

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: default avatarMengdong Lin <mengdong.lin@intel.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 25336e8a
...@@ -3433,11 +3433,16 @@ static struct snd_kcontrol_new spdif_share_sw = { ...@@ -3433,11 +3433,16 @@ static struct snd_kcontrol_new spdif_share_sw = {
int snd_hda_create_spdif_share_sw(struct hda_codec *codec, int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
struct hda_multi_out *mout) struct hda_multi_out *mout)
{ {
struct snd_kcontrol *kctl;
if (!mout->dig_out_nid) if (!mout->dig_out_nid)
return 0; 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 */ /* ATTENTION: here mout is passed as private_data, instead of codec */
return snd_hda_ctl_add(codec, mout->dig_out_nid, return snd_hda_ctl_add(codec, mout->dig_out_nid, kctl);
snd_ctl_new1(&spdif_share_sw, mout));
} }
EXPORT_SYMBOL_HDA(snd_hda_create_spdif_share_sw); EXPORT_SYMBOL_HDA(snd_hda_create_spdif_share_sw);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment