summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-11-04 07:43:08 (GMT)
committerTakashi Iwai <tiwai@suse.de>2008-11-04 07:43:08 (GMT)
commitb91f080f517cf9dd52023c11127a0ca33190e31a (patch)
tree04d660d1dc3bdbd9b229484a4bee66cc5559ae76
parent4ef0ef1966dae9e9e29762e4e719af3cfd146ca0 (diff)
downloadlinux-b91f080f517cf9dd52023c11127a0ca33190e31a.tar.xz
ALSA: hda - Fix possible NULL dereference
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>
-rw-r--r--sound/pci/hda/hda_codec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 8991db7..aa9cd14 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -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);
@@ -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];