mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
ALSA: cmipci: check snd_ctl_new1() return value
snd_ctl_new1() can return NULL when memory allocation fails.
snd_cmipci_spdif_controls() does not check the return value before
dereferencing kctl->id.device, which can lead to a NULL pointer
dereference.
Add NULL checks after snd_ctl_new1() calls and return -ENOMEM if any
fails.
Assisted-by: Opencode:DeepSeek-V4-Flash
Cc: stable@vger.kernel.org
Fixes: f2f312ad88 ("ALSA: cmipci: Fix kctl->id initialization")
Signed-off-by: Zhao Dongdong <zhaodongdong@kylinos.cn>
Link: https://patch.msgid.link/tencent_964433DCD132125D5EDA79EE068A2D6EFA09@qq.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
e64d170346
commit
c205bd1b28
|
|
@ -2637,16 +2637,22 @@ static int snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device)
|
|||
}
|
||||
if (cm->can_ac3_hw) {
|
||||
kctl = snd_ctl_new1(&snd_cmipci_spdif_default, cm);
|
||||
if (!kctl)
|
||||
return -ENOMEM;
|
||||
kctl->id.device = pcm_spdif_device;
|
||||
err = snd_ctl_add(card, kctl);
|
||||
if (err < 0)
|
||||
return err;
|
||||
kctl = snd_ctl_new1(&snd_cmipci_spdif_mask, cm);
|
||||
if (!kctl)
|
||||
return -ENOMEM;
|
||||
kctl->id.device = pcm_spdif_device;
|
||||
err = snd_ctl_add(card, kctl);
|
||||
if (err < 0)
|
||||
return err;
|
||||
kctl = snd_ctl_new1(&snd_cmipci_spdif_stream, cm);
|
||||
if (!kctl)
|
||||
return -ENOMEM;
|
||||
kctl->id.device = pcm_spdif_device;
|
||||
err = snd_ctl_add(card, kctl);
|
||||
if (err < 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user