snd_es1938_mixer() creates mixer controls with snd_ctl_new1() and then
stores hardware-volume pointers and private_free hooks in the returned
controls before calling snd_ctl_add(). snd_ctl_new1() can return NULL on
allocation failure, so these setup writes can dereference NULL.
Check the allocation result before using the control pointer.
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
sound/pci/es1938.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 280125eff3624..b6dcb721fffce 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -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;
--
2.34.1