Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: ops: dynamically allocate struct snd_ctl_elem_value

This structure is really too larget to be allocated on the stack:

sound/soc/soc-ops.c:435:5: error: stack frame size (1296) exceeds limit (1280) in 'snd_soc_limit_volume' [-Werror,-Wframe-larger-than]

Change the function to dynamically allocate it instead.

There is probably a better way to do it since only two integer fields
inside of that structure are actually used, but this is the simplest
rework for the moment.

Fixes: 783db6851c18 ("ASoC: ops: Enforce platform maximum on initial value")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://patch.msgid.link/20250610093057.2643233-1-arnd@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Arnd Bergmann and committed by
Mark Brown
7e10d724 2ccb7708

+16 -12
+16 -12
sound/soc/soc-ops.c
··· 399 399 static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl) 400 400 { 401 401 struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value; 402 - struct snd_ctl_elem_value uctl; 402 + struct snd_ctl_elem_value *uctl; 403 403 int ret; 404 404 405 405 if (!mc->platform_max) 406 406 return 0; 407 407 408 - ret = kctl->get(kctl, &uctl); 409 - if (ret < 0) 410 - return ret; 408 + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); 409 + if (!uctl) 410 + return -ENOMEM; 411 411 412 - if (uctl.value.integer.value[0] > mc->platform_max) 413 - uctl.value.integer.value[0] = mc->platform_max; 412 + ret = kctl->get(kctl, uctl); 413 + if (ret < 0) 414 + goto out; 415 + 416 + if (uctl->value.integer.value[0] > mc->platform_max) 417 + uctl->value.integer.value[0] = mc->platform_max; 414 418 415 419 if (snd_soc_volsw_is_stereo(mc) && 416 - uctl.value.integer.value[1] > mc->platform_max) 417 - uctl.value.integer.value[1] = mc->platform_max; 420 + uctl->value.integer.value[1] > mc->platform_max) 421 + uctl->value.integer.value[1] = mc->platform_max; 418 422 419 - ret = kctl->put(kctl, &uctl); 420 - if (ret < 0) 421 - return ret; 423 + ret = kctl->put(kctl, uctl); 422 424 423 - return 0; 425 + out: 426 + kfree(uctl); 427 + return ret; 424 428 } 425 429 426 430 /**