Skip to content

Commit

Permalink
ALSA: hda - check NULL pointer when creating SPDIF PCM switch
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
mengdonglin authored and tiwai committed Mar 7, 2013
1 parent 25336e8 commit 4c7a548
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sound/pci/hda/hda_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 4c7a548

Please sign in to comment.