[PATCH] ALSA: ice1712: aureon: check CS8415 control allocation

Ruoyu Wang posted 1 patch 1 day ago
sound/pci/ice1712/aureon.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] ALSA: ice1712: aureon: check CS8415 control allocation
Posted by Ruoyu Wang 1 day ago
aureon_add_controls() creates CS8415 controls and, for later entries,
adjusts kctl->id.device before adding the control. snd_ctl_new1() can
return NULL, so the device-id update can dereference NULL before the
control core sees the pointer.

Return -ENOMEM when the control allocation fails.

Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 sound/pci/ice1712/aureon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c
index 1191a2686dfd2..d6abff2978f3d 100644
--- a/sound/pci/ice1712/aureon.c
+++ b/sound/pci/ice1712/aureon.c
@@ -1891,6 +1891,8 @@ static int aureon_add_controls(struct snd_ice1712 *ice)
 			for (i = 0; i < ARRAY_SIZE(cs8415_controls); i++) {
 				struct snd_kcontrol *kctl;
 				kctl = snd_ctl_new1(&cs8415_controls[i], ice);
+				if (!kctl)
+					return -ENOMEM;
 				if (i > 1)
 					kctl->id.device = ice->pcm->device;
 				err = snd_ctl_add(ice->card, kctl);
-- 
2.34.1