]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ASoC: ops: dynamically allocate struct snd_ctl_elem_value
authorArnd Bergmann <arnd@arndb.de>
Tue, 10 Jun 2025 09:30:53 +0000 (11:30 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 10 Jun 2025 11:46:33 +0000 (12:46 +0100)
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>
sound/soc/soc-ops.c

index 8d4dd11c9aef1d93cae61d441f58bacb3ba21dc7..a629e0eacb20eb24980ea54754c634da15b67f66 100644 (file)
@@ -399,28 +399,32 @@ EXPORT_SYMBOL_GPL(snd_soc_put_volsw_sx);
 static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl)
 {
        struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;
-       struct snd_ctl_elem_value uctl;
+       struct snd_ctl_elem_value *uctl;
        int ret;
 
        if (!mc->platform_max)
                return 0;
 
-       ret = kctl->get(kctl, &uctl);
+       uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
+       if (!uctl)
+               return -ENOMEM;
+
+       ret = kctl->get(kctl, uctl);
        if (ret < 0)
-               return ret;
+               goto out;
 
-       if (uctl.value.integer.value[0] > mc->platform_max)
-               uctl.value.integer.value[0] = mc->platform_max;
+       if (uctl->value.integer.value[0] > mc->platform_max)
+               uctl->value.integer.value[0] = mc->platform_max;
 
        if (snd_soc_volsw_is_stereo(mc) &&
-           uctl.value.integer.value[1] > mc->platform_max)
-               uctl.value.integer.value[1] = mc->platform_max;
+           uctl->value.integer.value[1] > mc->platform_max)
+               uctl->value.integer.value[1] = mc->platform_max;
 
-       ret = kctl->put(kctl, &uctl);
-       if (ret < 0)
-               return ret;
+       ret = kctl->put(kctl, uctl);
 
-       return 0;
+out:
+       kfree(uctl);
+       return ret;
 }
 
 /**