linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: rt5682: Fix crash due to out of scope stack vars
@ 2021-11-18  1:04 Rob Clark
  2021-11-18  1:04 ` [PATCH 2/2] ASoC: rt5682s: " Rob Clark
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Rob Clark @ 2021-11-18  1:04 UTC (permalink / raw)
  To: alsa-devel
  Cc: Stephen Boyd, Derek Fang, linux-arm-msm, Rob Clark, Oder Chiou,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	open list

From: Rob Clark <robdclark@chromium.org>

Move the declaration of temporary arrays to somewhere that won't go out
of scope before the devm_clk_hw_register() call, lest we be at the whim
of the compiler for whether those stack variables get overwritten.

Fixes a crash seen with gcc version 11.2.1 20210728 (Red Hat 11.2.1-1)

Fixes: edbd24ea1e5c ("ASoC: rt5682: Drop usage of __clk_get_name()")
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
 sound/soc/codecs/rt5682.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 78b4cb5fb6c8..0d59ec2a5460 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -2844,6 +2844,8 @@ int rt5682_register_dai_clks(struct rt5682_priv *rt5682)
 
 	for (i = 0; i < RT5682_DAI_NUM_CLKS; ++i) {
 		struct clk_init_data init = { };
+		struct clk_parent_data parent_data;
+		const struct clk_hw *parent;
 
 		dai_clk_hw = &rt5682->dai_clks_hw[i];
 
@@ -2851,17 +2853,17 @@ int rt5682_register_dai_clks(struct rt5682_priv *rt5682)
 		case RT5682_DAI_WCLK_IDX:
 			/* Make MCLK the parent of WCLK */
 			if (rt5682->mclk) {
-				init.parent_data = &(struct clk_parent_data){
+				parent_data = (struct clk_parent_data){
 					.fw_name = "mclk",
 				};
+				init.parent_data = &parent_data;
 				init.num_parents = 1;
 			}
 			break;
 		case RT5682_DAI_BCLK_IDX:
 			/* Make WCLK the parent of BCLK */
-			init.parent_hws = &(const struct clk_hw *){
-				&rt5682->dai_clks_hw[RT5682_DAI_WCLK_IDX]
-			};
+			parent = &rt5682->dai_clks_hw[RT5682_DAI_WCLK_IDX];
+			init.parent_hws = &parent;
 			init.num_parents = 1;
 			break;
 		default:
-- 
2.33.1


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

* [PATCH 2/2] ASoC: rt5682s: Fix crash due to out of scope stack vars
  2021-11-18  1:04 [PATCH 1/2] ASoC: rt5682: Fix crash due to out of scope stack vars Rob Clark
@ 2021-11-18  1:04 ` Rob Clark
  2021-11-18  1:36   ` Stephen Boyd
  2021-11-18  1:36 ` [PATCH 1/2] ASoC: rt5682: " Stephen Boyd
  2021-11-27  1:29 ` Mark Brown
  2 siblings, 1 reply; 5+ messages in thread
From: Rob Clark @ 2021-11-18  1:04 UTC (permalink / raw)
  To: alsa-devel
  Cc: Stephen Boyd, Derek Fang, linux-arm-msm, Rob Clark, Oder Chiou,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	open list

From: Rob Clark <robdclark@chromium.org>

Move the declaration of temporary arrays to somewhere that won't go out
of scope before the devm_clk_hw_register() call, lest we be at the whim
of the compiler for whether those stack variables get overwritten.

Fixes a crash seen with gcc version 11.2.1 20210728 (Red Hat 11.2.1-1)

Fixes: bdd229ab26be ("ASoC: rt5682s: Add driver for ALC5682I-VS codec")
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
 sound/soc/codecs/rt5682s.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/rt5682s.c b/sound/soc/codecs/rt5682s.c
index 470957fcad6b..d49a4f68566d 100644
--- a/sound/soc/codecs/rt5682s.c
+++ b/sound/soc/codecs/rt5682s.c
@@ -2693,6 +2693,8 @@ static int rt5682s_register_dai_clks(struct snd_soc_component *component)
 
 	for (i = 0; i < RT5682S_DAI_NUM_CLKS; ++i) {
 		struct clk_init_data init = { };
+		struct clk_parent_data parent_data;
+		const struct clk_hw *parent;
 
 		dai_clk_hw = &rt5682s->dai_clks_hw[i];
 
@@ -2700,17 +2702,17 @@ static int rt5682s_register_dai_clks(struct snd_soc_component *component)
 		case RT5682S_DAI_WCLK_IDX:
 			/* Make MCLK the parent of WCLK */
 			if (rt5682s->mclk) {
-				init.parent_data = &(struct clk_parent_data){
+				parent_data = (struct clk_parent_data){
 					.fw_name = "mclk",
 				};
+				init.parent_data = &parent_data;
 				init.num_parents = 1;
 			}
 			break;
 		case RT5682S_DAI_BCLK_IDX:
 			/* Make WCLK the parent of BCLK */
-			init.parent_hws = &(const struct clk_hw *){
-				&rt5682s->dai_clks_hw[RT5682S_DAI_WCLK_IDX]
-			};
+			parent = &rt5682s->dai_clks_hw[RT5682S_DAI_WCLK_IDX];
+			init.parent_hws = &parent;
 			init.num_parents = 1;
 			break;
 		default:
-- 
2.33.1


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

* Re: [PATCH 1/2] ASoC: rt5682: Fix crash due to out of scope stack vars
  2021-11-18  1:04 [PATCH 1/2] ASoC: rt5682: Fix crash due to out of scope stack vars Rob Clark
  2021-11-18  1:04 ` [PATCH 2/2] ASoC: rt5682s: " Rob Clark
@ 2021-11-18  1:36 ` Stephen Boyd
  2021-11-27  1:29 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2021-11-18  1:36 UTC (permalink / raw)
  To: Rob Clark, alsa-devel
  Cc: Derek Fang, linux-arm-msm, Rob Clark, Oder Chiou, Liam Girdwood,
	Mark Brown, Jaroslav Kysela, Takashi Iwai, linux-kernel

Quoting Rob Clark (2021-11-17 17:04:52)
> From: Rob Clark <robdclark@chromium.org>
>
> Move the declaration of temporary arrays to somewhere that won't go out
> of scope before the devm_clk_hw_register() call, lest we be at the whim
> of the compiler for whether those stack variables get overwritten.
>
> Fixes a crash seen with gcc version 11.2.1 20210728 (Red Hat 11.2.1-1)
>
> Fixes: edbd24ea1e5c ("ASoC: rt5682: Drop usage of __clk_get_name()")
> Signed-off-by: Rob Clark <robdclark@chromium.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

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

* Re: [PATCH 2/2] ASoC: rt5682s: Fix crash due to out of scope stack vars
  2021-11-18  1:04 ` [PATCH 2/2] ASoC: rt5682s: " Rob Clark
@ 2021-11-18  1:36   ` Stephen Boyd
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2021-11-18  1:36 UTC (permalink / raw)
  To: Rob Clark, alsa-devel
  Cc: Derek Fang, linux-arm-msm, Rob Clark, Oder Chiou, Liam Girdwood,
	Mark Brown, Jaroslav Kysela, Takashi Iwai, linux-kernel

Quoting Rob Clark (2021-11-17 17:04:53)
> From: Rob Clark <robdclark@chromium.org>
>
> Move the declaration of temporary arrays to somewhere that won't go out
> of scope before the devm_clk_hw_register() call, lest we be at the whim
> of the compiler for whether those stack variables get overwritten.
>
> Fixes a crash seen with gcc version 11.2.1 20210728 (Red Hat 11.2.1-1)
>
> Fixes: bdd229ab26be ("ASoC: rt5682s: Add driver for ALC5682I-VS codec")
> Signed-off-by: Rob Clark <robdclark@chromium.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

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

* Re: [PATCH 1/2] ASoC: rt5682: Fix crash due to out of scope stack vars
  2021-11-18  1:04 [PATCH 1/2] ASoC: rt5682: Fix crash due to out of scope stack vars Rob Clark
  2021-11-18  1:04 ` [PATCH 2/2] ASoC: rt5682s: " Rob Clark
  2021-11-18  1:36 ` [PATCH 1/2] ASoC: rt5682: " Stephen Boyd
@ 2021-11-27  1:29 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2021-11-27  1:29 UTC (permalink / raw)
  To: alsa-devel, Rob Clark
  Cc: open list, linux-arm-msm, Jaroslav Kysela, Oder Chiou,
	Liam Girdwood, Derek Fang, Stephen Boyd, Takashi Iwai, Rob Clark

On Wed, 17 Nov 2021 17:04:52 -0800, Rob Clark wrote:
> From: Rob Clark <robdclark@chromium.org>
> 
> Move the declaration of temporary arrays to somewhere that won't go out
> of scope before the devm_clk_hw_register() call, lest we be at the whim
> of the compiler for whether those stack variables get overwritten.
> 
> Fixes a crash seen with gcc version 11.2.1 20210728 (Red Hat 11.2.1-1)
> 
> [...]

Applied to

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

Thanks!

[1/2] ASoC: rt5682: Fix crash due to out of scope stack vars
      commit: 4999d703c0e66f9f196b6edc0b8fdeca8846b8b6
[2/2] ASoC: rt5682s: Fix crash due to out of scope stack vars
      commit: 750dc2f622192c08664a15413bc9746d9cbc4361

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] 5+ messages in thread

end of thread, other threads:[~2021-11-27  1:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18  1:04 [PATCH 1/2] ASoC: rt5682: Fix crash due to out of scope stack vars Rob Clark
2021-11-18  1:04 ` [PATCH 2/2] ASoC: rt5682s: " Rob Clark
2021-11-18  1:36   ` Stephen Boyd
2021-11-18  1:36 ` [PATCH 1/2] ASoC: rt5682: " Stephen Boyd
2021-11-27  1:29 ` 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).