]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: es1938: check snd_ctl_new1() return value
authorZhao Dongdong <zhaodongdong@kylinos.cn>
Wed, 27 May 2026 12:09:09 +0000 (20:09 +0800)
committerTakashi Iwai <tiwai@suse.de>
Thu, 28 May 2026 07:34:41 +0000 (09:34 +0200)
snd_ctl_new1() can return NULL when memory allocation fails.
snd_es1938_mixer() does not check the return value before dereferencing
the pointer, 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: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Zhao Dongdong <zhaodongdong@kylinos.cn>
Link: https://patch.msgid.link/tencent_E0DC65165FDF2C8982BAFB6794B854B53B0A@qq.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/es1938.c

index f4c7a9532f4a6f81ee9cc6f386b48ab37e4d487b..217beb9376aca8250734eb5608be8c10e0ca7cb4 100644 (file)
@@ -1655,6 +1655,8 @@ static int snd_es1938_mixer(struct es1938 *chip)
        for (idx = 0; idx < ARRAY_SIZE(snd_es1938_controls); idx++) {
                struct snd_kcontrol *kctl;
                kctl = snd_ctl_new1(&snd_es1938_controls[idx], chip);
+               if (!kctl)
+                       return -ENOMEM;
                switch (idx) {
                        case 0:
                                chip->master_volume = kctl;