mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] ALSA: es18xx: check control allocation before private data setup
@ 2026-06-07  7:42 Ruoyu Wang
  2026-06-07  9:45 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Ruoyu Wang @ 2026-06-07  7:42 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela
  Cc: linux-sound, linux-kernel, alsa-devel, Ruoyu Wang

snd_es18xx_mixer() creates controls with snd_ctl_new1() and then stores
bookkeeping pointers or sets private_free before calling snd_ctl_add().
snd_ctl_new1() can return NULL on allocation failure, so those writes
can dereference a NULL control pointer.

Check the returned control pointers before using them and return -ENOMEM
on allocation failure.

Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
v2:
- Rebase on sound.git for-next.
- Resend only es18xx; the other v1 patches are already in for-next.

 sound/isa/es18xx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index df88d91e0fb..1a02da1679d 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -1762,6 +1762,8 @@ static int snd_es18xx_mixer(struct snd_card *card)
 	for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) {
 		struct snd_kcontrol *kctl;
 		kctl = snd_ctl_new1(&snd_es18xx_base_controls[idx], chip);
+		if (!kctl)
+			return -ENOMEM;
 		if (chip->caps & ES18XX_HWV) {
 			switch (idx) {
 			case 0:
@@ -1823,6 +1825,8 @@ static int snd_es18xx_mixer(struct snd_card *card)
 		for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_hw_volume_controls); idx++) {
 			struct snd_kcontrol *kctl;
 			kctl = snd_ctl_new1(&snd_es18xx_hw_volume_controls[idx], chip);
+			if (!kctl)
+				return -ENOMEM;
 			if (idx == 0)
 				chip->hw_volume = kctl;
 			else
-- 
2.51.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ALSA: es18xx: check control allocation before private data setup
  2026-06-07  7:42 [PATCH v2] ALSA: es18xx: check control allocation before private data setup Ruoyu Wang
@ 2026-06-07  9:45 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-06-07  9:45 UTC (permalink / raw)
  To: Ruoyu Wang
  Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel, alsa-devel

On Sun, 07 Jun 2026 09:42:19 +0200,
Ruoyu Wang wrote:
> 
> snd_es18xx_mixer() creates controls with snd_ctl_new1() and then stores
> bookkeeping pointers or sets private_free before calling snd_ctl_add().
> snd_ctl_new1() can return NULL on allocation failure, so those writes
> can dereference a NULL control pointer.
> 
> Check the returned control pointers before using them and return -ENOMEM
> on allocation failure.
> 
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
> v2:
> - Rebase on sound.git for-next.
> - Resend only es18xx; the other v1 patches are already in for-next.

Applied to for-next branch now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-07  9:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-07  7:42 [PATCH v2] ALSA: es18xx: check control allocation before private data setup Ruoyu Wang
2026-06-07  9:45 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®