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>
This commit is contained in:
parent
4ef0ef1966
commit
b91f080f51
1 changed files with 3 additions and 1 deletions
|
@ -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++) {
|
for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
|
||||||
kctl = snd_ctl_new1(dig_mix, codec);
|
kctl = snd_ctl_new1(dig_mix, codec);
|
||||||
|
if (!kctl)
|
||||||
|
return -ENOMEM;
|
||||||
kctl->id.index = idx;
|
kctl->id.index = idx;
|
||||||
kctl->private_value = nid;
|
kctl->private_value = nid;
|
||||||
err = snd_hda_ctl_add(codec, kctl);
|
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;
|
struct hda_pcm_stream *info;
|
||||||
int stream, err;
|
int stream, err;
|
||||||
|
|
||||||
if (!pcm->name)
|
if (snd_BUG_ON(!pcm->name))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
for (stream = 0; stream < 2; stream++) {
|
for (stream = 0; stream < 2; stream++) {
|
||||||
info = &pcm->stream[stream];
|
info = &pcm->stream[stream];
|
||||||
|
|
Loading…
Add table
Reference in a new issue