ARM/soc: Make sure clk_init_data is fully initialized
Subsystems (6)
cover ARM/soc: Make sure clk_init_data is fully initialized
Hi all,
The clk_init_data structure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is enabled.
Hence this series aims to make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents.
Part One[1] fixed all cases that I identified to be real bugs, in response to a crash I saw on BeagleBone Black.
This series is the ARM/soc subpart of Part Two, which fixes remaining cases that are currently harmless. These are still fragile, and may cause future breakage when converting drivers to a different method for specifying the parents.
Thanks for your comments!
[1] "[PATCH treewide 0/5] clk: Make sure clk_init_data is fully initialized (part 1)"
https://lore.kernel.org/[email protected]
Geert Uytterhoeven (2):
ARM: versatile: clock: Make sure clk_init_data is fully initialized soc/tegra: pmc: Make sure clk_init_data is fully initialized
arch/arm/mach-versatile/spc.c | 2 +- drivers/soc/tegra/pmc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 12 lines
2.43.0
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsPATCH 1/2 ARM: versatile: clock: Make sure clk_init_data is fully initialized
The clk_init_data structure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is enabled.
Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents.
---
Compile-tested only.
--- arch/arm/mach-versatile/spc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-versatile/spc.c +1 -1
@@ -522,7 +522,7 @@ static struct clk_ops clk_spc_ops = {static struct clk *ve_spc_clk_register (struct device *cpu_dev) { -struct clk_init_data init; +struct clk_init_data init = {};struct clk_spc *spc; spc =kzalloc_obj (*spc);
Signature · 1 line
2.43.0
Re: [PATCH 1/2] ARM: versatile: clock: Make sure clk_init_data is fully initialized
Quoted 7 lines · Geert Uytterhoeven
The
clk_init_datastructure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed whenCONFIG_INIT_STACK_ALL_PATTERNorCONFIG_INIT_STACK_NONEis enabled.
Quoted 5 lines
Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents.
Signed-off-by Geert Uytterhoeven <[email protected]>
Best regards,
Liviu
Quoted 22 lines
---
Compile-tested only.--- arch/arm/mach-versatile/spc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/mach-versatile/spc.c +1
-1@@ -522,7 +522,7 @@ static struct clk_ops clk_spc_ops = {static struct clk *ve_spc_clk_register (struct device *cpu_dev) { -struct clk_init_data init; +struct clk_init_data init = {};struct clk_spc *spc; spc =kzalloc_obj (*spc);Signature · 1 line
2.43.0
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Re: [PATCH 1/2] ARM: versatile: clock: Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoted 7 lines · Geert Uytterhoeven
The
clk_init_datastructure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed whenCONFIG_INIT_STACK_ALL_PATTERNorCONFIG_INIT_STACK_NONEis enabled.
Quoted 5 lines
Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents.
Signed-off-by Geert Uytterhoeven <[email protected]>
Looks right to me:
Yours,
Linus Walleij
PATCH 2/2 soc/tegra: pmc: Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenThe clk_init_data structure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is enabled.
Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents.
---
Compile-tested only.
--- drivers/soc/tegra/pmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/tegra/pmc.c +2 -2
@@ -2694,7 +2694,7 @@ tegra_pmc_clk_out_register(struct tegra_pmc *pmc, const struct pmc_clk_init_data *data, unsigned long offset) { -struct clk_init_data init; +struct clk_init_data init = {};struct pmc_clk *pmc_clk; pmc_clk =devm_kzalloc (pmc->dev,sizeof (*pmc_clk),GFP_KERNEL );
@@ -2752,7 +2752,7 @@ tegra_pmc_clk_gate_register(struct tegra_pmc *pmc, const char *name, const char *parent_name, unsigned long offset, u32 shift) { - struct clk_init_data init; + struct clk_init_data init = {};struct pmc_clk_gate *gate; gate =devm_kzalloc (pmc->dev,sizeof (*gate),GFP_KERNEL );
Signature · 1 line
2.43.0
Re: [PATCH 2/2] soc/tegra: pmc: Make sure clk_init_data is fully initialized
Quoted 7 lines · Geert Uytterhoeven
The
clk_init_datastructure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed whenCONFIG_INIT_STACK_ALL_PATTERNorCONFIG_INIT_STACK_NONEis enabled.
Quoted 5 lines
Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents.
Signed-off-by Geert Uytterhoeven <[email protected]>