[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vdy083+5K=4sViwg8uNJ1_6agECYbjMSFEGXX9VTO85WQ@mail.gmail.com>
Date: Sun, 14 Mar 2021 12:48:36 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Nick Desaulniers <nick.desaulniers@...il.com>
Cc: Julia Lawall <Julia.Lawall@...ia.fr>,
ALSA Development Mailing List <alsa-devel@...a-project.org>,
amadeuszx.slawinski@...ux.intel.com,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Mark Brown <broonie@...nel.org>,
Cezary Rojewski <cezary.rojewski@...el.com>,
guennadi.liakhovetski@...ux.intel.com,
Liam Girdwood <liam.r.girdwood@...ux.intel.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
mateusz.gorski@...ux.intel.com, Jaroslav Kysela <perex@...ex.cz>,
Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
Takashi Iwai <tiwai@...e.com>,
Jie Yang <yang.jie@...ux.intel.com>
Subject: Re: [PATCH v2] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than
On Sun, Mar 14, 2021 at 10:08 AM Nick Desaulniers
<nick.desaulniers@...il.com> wrote:
>
> Fixes:
> sound/soc/intel/skylake/skl-topology.c:3613:13: warning: stack frame
> size of 1304 bytes in function 'skl_tplg_complete'
> [-Wframe-larger-than=]
>
> struct snd_ctl_elem_value is 1224 bytes in my configuration.
>
> Heap allocate it, then free it within the current frame.
>
> Signed-off-by: Nick Desaulniers <nick.desaulniers@...il.com>
> ---
> Changes V1 -> V2: rebased on mainline.
>
> sound/soc/intel/skylake/skl-topology.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
> index b824086203b9..566d07b4b523 100644
> --- a/sound/soc/intel/skylake/skl-topology.c
> +++ b/sound/soc/intel/skylake/skl-topology.c
> @@ -3613,10 +3613,15 @@ static int skl_manifest_load(struct snd_soc_component *cmpnt, int index,
> static void skl_tplg_complete(struct snd_soc_component *component)
> {
> struct snd_soc_dobj *dobj;
> - struct snd_soc_acpi_mach *mach =
> - dev_get_platdata(component->card->dev);
> + struct snd_soc_acpi_mach *mach;
> + struct snd_ctl_elem_value *val;
> int i;
>
> + val = kzalloc(sizeof(*val), GFP_KERNEL);
> + if (!val)
> + return;
> +
> + mach = dev_get_platdata(component->card->dev);
> list_for_each_entry(dobj, &component->dobj_list, list) {
> struct snd_kcontrol *kcontrol = dobj->control.kcontrol;
> struct soc_enum *se;
> @@ -3632,14 +3637,13 @@ static void skl_tplg_complete(struct snd_soc_component *component)
> sprintf(chan_text, "c%d", mach->mach_params.dmic_num);
>
> for (i = 0; i < se->items; i++) {
> - struct snd_ctl_elem_value val = {};
Shouldn't you use rather kmalloc() + memset(). Otherwise I don't see
how possible this won't be garbage on the second iteration of the
outer loop.
> -
> if (strstr(texts[i], chan_text)) {
> - val.value.enumerated.item[0] = i;
> - kcontrol->put(kcontrol, &val);
> + val->value.enumerated.item[0] = i;
> + kcontrol->put(kcontrol, val);
> }
> }
> }
> + kfree(val);
> }
>
> static struct snd_soc_tplg_ops skl_tplg_ops = {
>
> base-commit: 88fe49249c99de14e543c632a46248d85411ab9e
> --
> 2.25.1
>
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists