Skip to content

Commit

Permalink
ALSA: hda - Fix possible NULL dereference
Browse files Browse the repository at this point in the history
Add NULL-check of the return value of snd_kctl_new1() before
accessing it.  Also, make a sanity NULL check to snd_BUG_ON()
for debugging only.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Nov 4, 2008
1 parent 4ef0ef1 commit b91f080
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sound/pci/hda/hda_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,8 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
}
for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
kctl = snd_ctl_new1(dig_mix, codec);
if (!kctl)
return -ENOMEM;
kctl->id.index = idx;
kctl->private_value = nid;
err = snd_hda_ctl_add(codec, kctl);
Expand Down Expand Up @@ -2412,7 +2414,7 @@ snd_hda_attach_pcm(struct hda_codec *codec, struct hda_pcm *pcm)
struct hda_pcm_stream *info;
int stream, err;

if (!pcm->name)
if (snd_BUG_ON(!pcm->name))
return -EINVAL;
for (stream = 0; stream < 2; stream++) {
info = &pcm->stream[stream];
Expand Down

0 comments on commit b91f080

Please sign in to comment.