From: Zhao Dongdong <winter91@foxmail.com>
To: perex@perex.cz, tiwai@suse.com
Cc: linux-sound@vger.kernel.org,
Zhao Dongdong <zhaodongdong@kylinos.cn>,
stable@vger.kernel.org
Subject: [PATCH v3 2/6] ALSA: gus: check snd_ctl_new1() return value
Date: Wed, 27 May 2026 20:09:10 +0800 [thread overview]
Message-ID: <tencent_F644A3DCAD32945D62DB2FEEBE8A996F6809@qq.com> (raw)
In-Reply-To: <20260527120914.515037-1-winter91@foxmail.com>
From: Zhao Dongdong <zhaodongdong@kylinos.cn>
snd_ctl_new1() can return NULL when memory allocation fails.
snd_gf1_pcm_volume_control() does not check the return value before
dereferencing kctl->id.index, which can lead to a NULL pointer
dereference.
Add a NULL check after snd_ctl_new1() and return -ENOMEM if it fails.
Assisted-by: Opencode:DeepSeek-V4-Flash
Cc: stable@vger.kernel.org
Fixes: c5ae57b1bb99 ("ALSA: gus: Fix kctl->id initialization")
Signed-off-by: Zhao Dongdong <zhaodongdong@kylinos.cn>
---
sound/isa/gus/gus_pcm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c
index a0757e1ede46..08ccb4d80ade 100644
--- a/sound/isa/gus/gus_pcm.c
+++ b/sound/isa/gus/gus_pcm.c
@@ -851,6 +851,8 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index)
kctl = snd_ctl_new1(&snd_gf1_pcm_volume_control1, gus);
else
kctl = snd_ctl_new1(&snd_gf1_pcm_volume_control, gus);
+ if (!kctl)
+ return -ENOMEM;
kctl->id.index = control_index;
err = snd_ctl_add(card, kctl);
if (err < 0)
--
2.25.1
next prev parent reply other threads:[~2026-05-27 12:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260527120914.515037-1-winter91@foxmail.com>
2026-05-27 12:09 ` [PATCH v3 1/6] ALSA: es1938: check snd_ctl_new1() return value Zhao Dongdong
2026-05-27 12:09 ` Zhao Dongdong [this message]
2026-05-27 12:09 ` [PATCH v3 3/6] ALSA: ice1712: " Zhao Dongdong
2026-05-27 12:09 ` [PATCH v3 4/6] ALSA: ymfpci: " Zhao Dongdong
2026-05-27 12:09 ` [PATCH v3 5/6] ALSA: cmipci: " Zhao Dongdong
2026-05-27 12:09 ` [PATCH v3 6/6] ALSA: aoa: " Zhao Dongdong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_F644A3DCAD32945D62DB2FEEBE8A996F6809@qq.com \
--to=winter91@foxmail.com \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.com \
--cc=zhaodongdong@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.