Skip to content

Commit b908999

Browse files
committed
ASoC: ops: dynamically allocate struct snd_ctl_elem_value
JIRA: https://issues.redhat.com/browse/RHEL-101627 commit 7e10d72 Author: Arnd Bergmann <arnd@arndb.de> Date: Tue Jun 10 11:30:53 2025 +0200 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: 783db68 ("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> Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
1 parent fd6e4da commit b908999

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

sound/soc/soc-ops.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -399,28 +399,32 @@ EXPORT_SYMBOL_GPL(snd_soc_put_volsw_sx);
399399
static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl)
400400
{
401401
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;
403403
int ret;
404404

405405
if (!mc->platform_max)
406406
return 0;
407407

408-
ret = kctl->get(kctl, &uctl);
408+
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
409+
if (!uctl)
410+
return -ENOMEM;
411+
412+
ret = kctl->get(kctl, uctl);
409413
if (ret < 0)
410-
return ret;
414+
goto out;
411415

412-
if (uctl.value.integer.value[0] > mc->platform_max)
413-
uctl.value.integer.value[0] = mc->platform_max;
416+
if (uctl->value.integer.value[0] > mc->platform_max)
417+
uctl->value.integer.value[0] = mc->platform_max;
414418

415419
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;
418422

419-
ret = kctl->put(kctl, &uctl);
420-
if (ret < 0)
421-
return ret;
423+
ret = kctl->put(kctl, uctl);
422424

423-
return 0;
425+
out:
426+
kfree(uctl);
427+
return ret;
424428
}
425429

426430
/**

0 commit comments

Comments
 (0)