diff options
author | Takashi Iwai <tiwai@suse.de> | 2008-11-04 02:43:08 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-11-04 02:43:08 -0500 |
commit | b91f080f517cf9dd52023c11127a0ca33190e31a (patch) | |
tree | 04d660d1dc3bdbd9b229484a4bee66cc5559ae76 /sound/pci/hda/hda_codec.c | |
parent | 4ef0ef1966dae9e9e29762e4e719af3cfd146ca0 (diff) |
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>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 8991db78fb67..aa9cd142c30a 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) | |||
1697 | } | 1697 | } |
1698 | for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { | 1698 | for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { |
1699 | kctl = snd_ctl_new1(dig_mix, codec); | 1699 | kctl = snd_ctl_new1(dig_mix, codec); |
1700 | if (!kctl) | ||
1701 | return -ENOMEM; | ||
1700 | kctl->id.index = idx; | 1702 | kctl->id.index = idx; |
1701 | kctl->private_value = nid; | 1703 | kctl->private_value = nid; |
1702 | err = snd_hda_ctl_add(codec, kctl); | 1704 | err = snd_hda_ctl_add(codec, kctl); |
@@ -2412,7 +2414,7 @@ snd_hda_attach_pcm(struct hda_codec *codec, struct hda_pcm *pcm) | |||
2412 | struct hda_pcm_stream *info; | 2414 | struct hda_pcm_stream *info; |
2413 | int stream, err; | 2415 | int stream, err; |
2414 | 2416 | ||
2415 | if (!pcm->name) | 2417 | if (snd_BUG_ON(!pcm->name)) |
2416 | return -EINVAL; | 2418 | return -EINVAL; |
2417 | for (stream = 0; stream < 2; stream++) { | 2419 | for (stream = 0; stream < 2; stream++) { |
2418 | info = &pcm->stream[stream]; | 2420 | info = &pcm->stream[stream]; |