linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than
@ 2021-03-14  7:44 Nick Desaulniers
  2021-03-14  8:06 ` [PATCH v2] " Nick Desaulniers
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Desaulniers @ 2021-03-14  7:44 UTC (permalink / raw)
  To: Cezary Rojewski, Pierre-Louis Bossart, Liam Girdwood, Jie Yang
  Cc: Nick Desaulniers, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Mateusz Gorski, Guennadi Liakhovetski, Julia Lawall,
	Andy Shevchenko, Amadeusz Sławiński, alsa-devel,
	linux-kernel

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@gmail.com>
---
 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 ae466cd59292..cdc916c91301 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 =
@@ -3631,14 +3636,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;
-
 			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: 65f0d2414b7079556fbbcc070b3d1c9f9587606d
prerequisite-patch-id: 4d05aad8c2b50c0c3b4447dd842abe8b1b840927
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than
  2021-03-14  7:44 [PATCH] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than Nick Desaulniers
@ 2021-03-14  8:06 ` Nick Desaulniers
  2021-03-14 10:48   ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Desaulniers @ 2021-03-14  8:06 UTC (permalink / raw)
  To: nick.desaulniers
  Cc: Julia.Lawall, alsa-devel, amadeuszx.slawinski, andriy.shevchenko,
	broonie, cezary.rojewski, guennadi.liakhovetski, liam.r.girdwood,
	linux-kernel, mateusz.gorski, perex, pierre-louis.bossart, tiwai,
	yang.jie

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@gmail.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 = {};
-
 			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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than
  2021-03-14  8:06 ` [PATCH v2] " Nick Desaulniers
@ 2021-03-14 10:48   ` Andy Shevchenko
  2021-03-15  1:39     ` [PATCH v3] " Nick Desaulniers
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2021-03-14 10:48 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Julia Lawall, ALSA Development Mailing List, amadeuszx.slawinski,
	Andy Shevchenko, Mark Brown, Cezary Rojewski,
	guennadi.liakhovetski, Liam Girdwood, Linux Kernel Mailing List,
	mateusz.gorski, Jaroslav Kysela, Pierre-Louis Bossart,
	Takashi Iwai, Jie Yang

On Sun, Mar 14, 2021 at 10:08 AM Nick Desaulniers
<nick.desaulniers@gmail.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@gmail.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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than
  2021-03-14 10:48   ` Andy Shevchenko
@ 2021-03-15  1:39     ` Nick Desaulniers
  2021-03-18 13:52       ` Mark Brown
  2021-03-18 18:33       ` Mark Brown
  0 siblings, 2 replies; 7+ messages in thread
From: Nick Desaulniers @ 2021-03-15  1:39 UTC (permalink / raw)
  To: nick.desaulniers
  Cc: Julia.Lawall, alsa-devel, amadeuszx.slawinski, andriy.shevchenko,
	broonie, cezary.rojewski, guennadi.liakhovetski, liam.r.girdwood,
	linux-kernel, mateusz.gorski, perex, pierre-louis.bossart, tiwai,
	Andy Shevchenko, yang.jie

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.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
---
Changes V2 -> V3:
* change to kmalloc+memset to fix logic error, as per Andy.
Changes V1 -> V2:
* rebased on mainline.

 sound/soc/intel/skylake/skl-topology.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index b824086203b9..c0fdab39e7c2 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 = kmalloc(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,14 @@ 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 = {};
-
 			if (strstr(texts[i], chan_text)) {
-				val.value.enumerated.item[0] = i;
-				kcontrol->put(kcontrol, &val);
+				memset(val, 0, sizeof(*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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than
  2021-03-15  1:39     ` [PATCH v3] " Nick Desaulniers
@ 2021-03-18 13:52       ` Mark Brown
  2021-03-18 18:33       ` Mark Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Brown @ 2021-03-18 13:52 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: guennadi.liakhovetski, cezary.rojewski, liam.r.girdwood,
	mateusz.gorski, yang.jie, alsa-devel, linux-kernel, Julia.Lawall,
	Andy Shevchenko, amadeuszx.slawinski, tiwai, andriy.shevchenko,
	pierre-louis.bossart

[-- Attachment #1: Type: text/plain, Size: 372 bytes --]

On Sun, Mar 14, 2021 at 06:39:08PM -0700, Nick Desaulniers 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=]

Changelogs like this look like Fixes: tags and confuse tools which
attempt to parse them, please don't just put a Fixes: at the start of
the line.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than
  2021-03-15  1:39     ` [PATCH v3] " Nick Desaulniers
  2021-03-18 13:52       ` Mark Brown
@ 2021-03-18 18:33       ` Mark Brown
  2021-03-18 18:36         ` Mark Brown
  1 sibling, 1 reply; 7+ messages in thread
From: Mark Brown @ 2021-03-18 18:33 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Mark Brown, Andy Shevchenko, alsa-devel, guennadi.liakhovetski,
	pierre-louis.bossart, andriy.shevchenko, Julia.Lawall, tiwai,
	mateusz.gorski, linux-kernel, cezary.rojewski, yang.jie,
	amadeuszx.slawinski, liam.r.girdwood

On Sun, 14 Mar 2021 18:39:08 -0700, Nick Desaulniers 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than
      commit: bef2897d31b97852d80b38e9376ed5ef3a90b309

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than
  2021-03-18 18:33       ` Mark Brown
@ 2021-03-18 18:36         ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2021-03-18 18:36 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Mark Brown, Andy Shevchenko, alsa-devel, guennadi.liakhovetski,
	pierre-louis.bossart, andriy.shevchenko, Julia.Lawall, tiwai,
	mateusz.gorski, linux-kernel, cezary.rojewski, yang.jie,
	amadeuszx.slawinski, liam.r.girdwood

On Sun, 14 Mar 2021 18:39:08 -0700, Nick Desaulniers 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than
      commit: bef2897d31b97852d80b38e9376ed5ef3a90b309

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-18 18:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-14  7:44 [PATCH] ASoC: Intel: Skylake: skl-topology: fix -frame-larger-than Nick Desaulniers
2021-03-14  8:06 ` [PATCH v2] " Nick Desaulniers
2021-03-14 10:48   ` Andy Shevchenko
2021-03-15  1:39     ` [PATCH v3] " Nick Desaulniers
2021-03-18 13:52       ` Mark Brown
2021-03-18 18:33       ` Mark Brown
2021-03-18 18:36         ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).