clk: Make sure clk_init_data is fully initialized (part 1)
Subsystems (11)
cover clk: Make sure clk_init_data is fully initialized (part 1)
Hi all,
The clk_init_data structure contains three mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. When commit fc0c209c147f35ed ("clk: Allow parents to be specified without string names") added the last two methods, this was done in a backwards-compatible way, using a priority-based scheme:
- .name, .ops, .num_parents, and .flags must always be initialized,
- if .num_parents is non-zero, .parent_names must be initialized,
- if .parent_names is NULL, .parent_data must be initialized,
- if .parent_data is NULL, .parent_hws must be initialized and valid.
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 makes sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
This (small) series is part 1, and fixes all cases that I identified to be real bugs:
- The first patch fixes a crash I saw on BeagleBone Black,
- The other patches are only compile-tested.
All patches in this series can be applied independently.
Part 2 will be much larger (touching 185 files), and will fix the remaining cases that are currently harmless.
Thanks for your comments!
Geert Uytterhoeven (5):
clk: ti: Make sure clk_init_data is fully initialized
clk: visconti: Make sure clk_init_data is fully initialized
hwmon: (ltc4282) Make sure clk_init_data is fully initialized
iio: frequency: adf4377: Make sure clk_init_data is fully initialized
spi: amlogic-spisg: Make sure clk_init_data is fully initialized
drivers/clk/ti/adpll.c | 4 ++-- drivers/clk/ti/divider.c | 2 +- drivers/clk/ti/mux.c | 2 +- drivers/clk/visconti/clkc.c | 2 +- drivers/hwmon/ltc4282.c | 2 +- drivers/iio/frequency/adf4377.c | 2 +- drivers/spi/spi-amlogic-spisg.c | 2 +- 7 files changed, 8 insertions(+), 8 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/5 clk: ti: 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.
_register_mux() fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
--- drivers/clk/ti/adpll.c | 4 ++-- drivers/clk/ti/divider.c | 2 +- drivers/clk/ti/mux.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/clk/ti/adpll.c +2 -2
@@ -483,7 +483,7 @@ static const struct clk_ops ti_adpll_ops = {static int ti_adpll_init_dco (struct ti_adpll_data *d) { -struct clk_init_data init; +struct clk_init_data init = {};struct clk *clock;const char *postfix;int width, err;
@@ -576,7 +576,7 @@ static int ti_adpll_init_clkout(struct ti_adpll_data *d, struct clk *clk1) {struct ti_adpll_clkout_data *co; -struct clk_init_data init; +struct clk_init_data init = {};struct clk_ops *ops;const char *parent_names[2 ];const char *child_name;
drivers/clk/ti/divider.c +1 -1
@@ -311,7 +311,7 @@ static struct clk *_register_divider(struct device_node *node,u32 flags, struct clk_omap_divider *div) { - struct clk_init_data init; + struct clk_init_data init = {};const char *parent_name;const char *name;
drivers/clk/ti/mux.c +1 -1
@@ -124,9 +124,9 @@ static struct clk *_register_mux(struct device_node *node, const char *name, struct clk_omap_reg *reg, u8 shift, u32 mask, s8 latch, u8 clk_mux_flags, u32 *table) { + struct clk_init_data init = {};struct clk_omap_mux *mux;struct clk *clk; -struct clk_init_data init;/* allocate the mux */ mux =kzalloc_obj (*mux);
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH treewide 1/5] clk: ti: Make sure clk_init_data is fully initialized
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines
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.
_register_mux()fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 7 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes 667f420c09f1417c ("clk: ti: mux: resolve parent clocks by DT index, not by name")Closes https://lore.kernel.org/CAMuHMdU3yVqoyHC4eNF2NuYo8wy+6ODLoYat4R71X99Mxc_=kw@mail.gmail.com open hereSigned-off-by Geert Uytterhoeven <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH treewide 1/5] clk: ti: Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoted 11 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.
_register_mux()fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 7 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes 667f420c09f1417c ("clk: ti: mux: resolve parent clocks by DT index, not by name")Closes https://lore.kernel.org/CAMuHMdU3yVqoyHC4eNF2NuYo8wy+6ODLoYat4R71X99Mxc_=kw@mail.gmail.com open hereSigned-off-by Geert Uytterhoeven <[email protected]>
Re: [PATCH treewide 1/5] clk: ti: Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoted 11 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.
_register_mux()fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 8 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes 667f420c09f1417c ("clk: ti: mux: resolve parent clocks by DT index, not by name")Closes https://lore.kernel.org/CAMuHMdU3yVqoyHC4eNF2NuYo8wy+6ODLoYat4R71X99Mxc_=kw@mail.gmail.com open hereSigned-off-by Geert Uytterhoeven <[email protected]>---
Thanks again for the fix.
Re: [PATCH treewide 1/5] clk: ti: Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoting Geert Uytterhoeven (2026-08-19 12:05:15)
Quoted 11 lines
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.
_register_mux()fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 8 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes 667f420c09f1417c ("clk: ti: mux: resolve parent clocks by DT index, not by name")Closes https://lore.kernel.org/CAMuHMdU3yVqoyHC4eNF2NuYo8wy+6ODLoYat4R71X99Mxc_=kw@mail.gmail.com open hereSigned-off-by Geert Uytterhoeven <[email protected]>---
Applied to clk-next
PATCH 2/5 clk: visconti: 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.
visconti_clk_register_gate() fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
---
Compile-tested only.
--- drivers/clk/visconti/clkc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/visconti/clkc.c +1 -1
@@ -81,9 +81,9 @@ static struct clk_hw *visconti_clk_register_gate(struct device *dev,u8 rs_idx, spinlock_t *lock) { + struct clk_init_data init = {};struct visconti_clk_gate *gate;struct clk_parent_data *pdata; -struct clk_init_data init;struct clk_hw *hw;int ret;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH treewide 2/5] clk: visconti: Make sure clk_init_data is fully initialized
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] visconti_reset_status() incorrectly uses the bit index directly instead of a bitmask, resulting in corrupted status checks. --
--- Patch [2]: [PATCH treewide 2/5] clk: visconti: Make sure clk_init_data is fully initialized --- commit 61772ea3c610a3b3ebf435b199e400c1c5aaee4c
Author: Geert Uytterhoeven <[email protected]>
clk: visconti: 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. Not initializing all members may cause subtle issues when uninitialized members are unexpectedly accessed. This commit ensures all members are fully initialized to zero.
Quoted 5 lines
drivers/clk/visconti/clkc.c +0
-0
drivers/clk/visconti/clkc.c static struct clk_hw *visconti_clk_register_gate(struct device *dev, · line 89
Quoted 10 lines
drivers/clk/visconti/clkc.c +1
-1@@ -81,9 +81,9 @@ static struct clk_hw *visconti_clk_register_gate(struct device *dev,u8 rs_idx, spinlock_t *lock) { + struct clk_init_data init = {};struct visconti_clk_gate *gate;struct clk_parent_data *pdata; -struct clk_init_data init;struct clk_hw *hw;int ret;
[Severity: High]
This is a pre-existing issue, but while reviewing the visconti clock and reset driver changes, I noticed a potential problem with how rs_idx is used.
In drivers/clk/visconti/reset.c:visconti_reset_status():
spin_lock_irqsave(reset->lock, flags); ret = regmap_read(reset->regmap, data->rson_offset, ®); spin_unlock_irqrestore(reset->lock, flags); if (ret) return ret; return !(reg & data->rs_idx);
Is this reset status check operating as intended? Since rs_idx is a raw bit index (0-31), would it be more accurate to mask the register with BIT(data->rs_idx) rather than the raw index value?
Masking with the raw index seems like it could produce incorrect status returns. For example, if rs_idx is 0, the mask would always evaluate to 0.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH treewide 2/5] clk: visconti: Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoted 11 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.
visconti_clk_register_gate()fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 6 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes b4cbe606dc3674b2 ("clk: visconti: Add support common clock driver and reset driver")Signed-off-by Geert Uytterhoeven <[email protected]>
RE: [PATCH treewide 2/5] clk: visconti: Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoted 34 lines
-----Original Message-----
From: Geert Uytterhoeven <[email protected]>
Sent: Thursday, August 20, 2026 4:05 AM
To: Tero Kristo <[email protected]>; Stephen Boyd <[email protected]>; Brian Masney <[email protected]>; Jerome Brunet <[email protected]>; iwamatsu nobuhiro(岩松 信洋 □DITC○C
PT) <[email protected]>; Nuno Sa <[email protected]>; Guenter Roeck <[email protected]>; Michael Hennerich <[email protected]>; Antoniu Miclaus <[email protected]>; Jonathan Cameron <[email protected]>; David Lechner <[email protected]>; Andy Shevchenko <[email protected]>; Sunny Luo <[email protected]>; Xianwei Zhao <[email protected]>; Mark Brown <[email protected]>; Kees Cook <[email protected]>; Kevin Hilman <[email protected]>; Mathieu Dubois-Briand <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Geert Uytterhoeven <[email protected]>
Subject: [PATCH treewide 2/5] clk: visconti: Make sureclk_init_datais fully initializedThe
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.
visconti_clk_register_gate()fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 7 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes b4cbe606dc3674b2 ("clk: visconti: Add support common clock driverand reset driver")
Signed-off-by Geert Uytterhoeven <[email protected]>
Best regards,
Nobuhiro
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
Re: [PATCH treewide 2/5] clk: visconti: Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoting Geert Uytterhoeven (2026-08-19 12:05:16)
Quoted 11 lines
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.
visconti_clk_register_gate()fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 7 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes b4cbe606dc3674b2 ("clk: visconti: Add support common clock driver and reset driver")Signed-off-by Geert Uytterhoeven <[email protected]>---
Applied to clk-next
PATCH 3/5 hwmon: (ltc4282) 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.
ltc428_clk_provider_setup() does not fill in any parent clocks, and assumes that init.num_parents is NULL. However, the latter in uninitialized, and thus may cause a crash.
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
---
Compile-tested only.
--- drivers/hwmon/ltc4282.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/ltc4282.c +1 -1
@@ -1106,7 +1106,7 @@ static const struct clk_ops ltc4282_ops = {static int ltc428_clk_provider_setup (struct ltc4282_state *st,struct device *dev) { -struct clk_init_data init; +struct clk_init_data init = {};int ret;if (!IS_ENABLED (CONFIG_COMMON_CLK ))
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH treewide 3/5] hwmon: (ltc4282) Make sure clk_init_data is fully initialized
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines
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.
ltc428_clk_provider_setup()does not fill in any parent clocks, and assumes that init.num_parents is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 6 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes cbc29538dbf7d740 ("hwmon: Add driver for LTC4282")Signed-off-by Geert Uytterhoeven <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH treewide 3/5] hwmon: (ltc4282) Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoted 11 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.
ltc428_clk_provider_setup()does not fill in any parent clocks, and assumes that init.num_parents is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 6 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes cbc29538dbf7d740 ("hwmon: Add driver for LTC4282")Signed-off-by Geert Uytterhoeven <[email protected]>
Applied.
Thanks,
Guenter
Quoted 19 lines
---
Compile-tested only.--- drivers/hwmon/ltc4282.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/ltc4282.c +1
-1@@ -1106,7 +1106,7 @@ static const struct clk_ops ltc4282_ops = {static int ltc428_clk_provider_setup (struct ltc4282_state *st,struct device *dev) { -struct clk_init_data init; +struct clk_init_data init = {};int ret;if (!IS_ENABLED (CONFIG_COMMON_CLK ))
Re: [PATCH treewide 3/5] hwmon: (ltc4282) Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoted 11 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.
ltc428_clk_provider_setup()does not fill in any parent clocks, and assumes that init.num_parents is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 6 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes cbc29538dbf7d740 ("hwmon: Add driver for LTC4282")Signed-off-by Geert Uytterhoeven <[email protected]>
PATCH 4/5 iio: frequency: adf4377: 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.
adf4377_clk_register() fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
---
Compile-tested only.
--- drivers/iio/frequency/adf4377.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/frequency/adf4377.c +1 -1
@@ -990,7 +990,7 @@ static int adf4377_clk_register(struct adf4377_state *st) {struct spi_device *spi = st->spi;struct device *dev = &spi->dev; -struct clk_init_data init; +struct clk_init_data init = {};struct clk_parent_data parent_data;int ret;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH treewide 4/5] iio: frequency: adf4377: Make sure clk_init_data is fully initialized
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Incomplete fix for uninitialized stack variables: struct clk_parent_data parent_data remains uninitialized on the stack, leading to a kernel crash during clock registration. --
--- Patch [4]: [PATCH treewide 4/5] iio: frequency: adf4377: Make sure clk_init_data is fully initialized --- commit 99e024a77f5bce5921d3c6b46054263aa450610d
Author: Geert Uytterhoeven <[email protected]>
iio: frequency: adf4377: Make sure clk_init_data is fully initialized
This commit initializes the clk_init_data structure in adf4377_clk_register() to zero. This prevents crashes caused by uninitialized fields like parent_names when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is enabled.
drivers/iio/frequency/adf4377.c static int adf4377_clk_register(struct adf4377_state *st) · line 1003
Quoted 10 lines
drivers/iio/frequency/adf4377.c +1
-1@@ -999,7 +999,7 @@ static int adf4377_clk_register(struct adf4377_state *st) {struct spi_device *spi = st->spi;struct device *dev = &spi->dev; -struct clk_init_data init; +struct clk_init_data init = {};struct clk_parent_data parent_data;
[Severity: High]
This is a pre-existing issue, but does this struct clk_parent_data also need to be zero-initialized?
Only fw_name is explicitly assigned below, leaving name, hw, and index populated with stack garbage. When adf4377_clk_register() passes this to the clock framework, clk_core_populate_parent_map() will read parent_data.name and pass it to clk_cpy_name(), which ultimately calls strlen() and can cause a page fault during probe.
[ ... ]
Quoted 4 lines
drivers/iio/frequency/adf4377.c +0
-0parent_data.fw_name ="ref_in" ;drivers/iio/frequency/adf4377.c +0
-0init.ops = &adf4377_clk_ops; init.parent_data = &parent_data;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH treewide 4/5] iio: frequency: adf4377: Make sure clk_init_data is fully initialized
Hi Sashiko,
Quoted 32 lines · On Wed, 19 Aug 2026 at 21:13, <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Incomplete fix for uninitialized stack variables:struct clk_parent_data parent_dataremains uninitialized on the stack, leading to a kernel crash during clock registration. ----- Patch [4]: [PATCH treewide 4/5] iio: frequency: adf4377: Make sure
clk_init_datais fully initialized --- commit99e024a77f5bce5921d3c6b46054263aa450610d
Author: Geert Uytterhoeven <[email protected]>iio: frequency: adf4377: Make sure
clk_init_datais fully initializedThis commit initializes the
clk_init_datastructure inadf4377_clk_register()to zero. This prevents crashes caused by uninitialized fields likeparent_nameswhenCONFIG_INIT_STACK_ALL_PATTERNorCONFIG_INIT_STACK_NONEis enabled.drivers/iio/frequency/adf4377.c static int adf4377_clk_register(struct adf4377_state *st) · line 1003
Quoted 10 lines
drivers/iio/frequency/adf4377.c +1
-1@@ -999,7 +999,7 @@ static int adf4377_clk_register(struct adf4377_state *st) {struct spi_device *spi = st->spi;struct device *dev = &spi->dev; -struct clk_init_data init; +struct clk_init_data init = {};struct clk_parent_data parent_data;[Severity: High]
This is a pre-existing issue, but does this structclk_parent_dataalso need to be zero-initialized?
Quoted 5 lines
Only
fw_nameis explicitly assigned below, leaving name, hw, and index populated with stack garbage. Whenadf4377_clk_register()passes this to the clock framework,clk_core_populate_parent_map()will read parent_data.name and pass it toclk_cpy_name(), which ultimately callsstrlen()and can cause a page fault during probe.
Yes, parent_data has the same issue.
As Jonathan will rebase against rc1 anyway, I will send a v2. Thanks!
Quoted 10 lines
[ ... ]
Quoted 4 lines
parent_data.fw_name = "ref_in"; init.ops = &adf4377_clk_ops; init.parent_data = &parent_data;--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
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 Torvalds
Re: [PATCH treewide 4/5] iio: frequency: adf4377: Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoted 11 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.
adf4377_clk_register()fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 6 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes 60e5448ddbec2dc2 ("iio: frequency: adf4377: add clk provider support")Signed-off-by Geert Uytterhoeven <[email protected]>
Re: [PATCH treewide 4/5] iio: frequency: adf4377: Make sure clk_init_data is fully initialized
Quoted 12 lines · On Wed, 19 Aug 2026 17:22:41 -0400 Brian Masney <[email protected]> wrote:
Quoted 11 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.
adf4377_clk_register()fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 9 lines
Quoted 6 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes 60e5448ddbec2dc2 ("iio: frequency: adf4377: add clk provider support")Signed-off-by Geert Uytterhoeven <[email protected]>Reviewed-by Brian Masney <[email protected]>
Applied to the fixes-togreg branch of iio.git
I'll rebase on rc1 before sending a pull request (so waiting for that to be available)
Thanks,
Jonathan
PATCH 5/5 spi: amlogic-spisg: 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.
aml_spisg_clk_init() fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
---
Compile-tested only.
--- drivers/spi/spi-amlogic-spisg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-amlogic-spisg.c +1 -1
@@ -636,7 +636,7 @@ static int aml_spisg_target_abort(struct spi_controller *ctlr)static int aml_spisg_clk_init (struct spisg_device *spisg,void __iomem *base) {struct device *dev = &spisg->pdev->dev; -struct clk_init_data init; +struct clk_init_data init = {};struct clk_divider *div;struct clk_div_table *tbl;char name[32 ];
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH treewide 5/5] spi: amlogic-spisg: Make sure clk_init_data is fully initialized
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Severe imbalance in clock prepare/enable counts for pclk and core clocks, leading to negative enable counts and warnings during driver probe failure or removal.
- [High] Missing cleanup for runtime PM and sclk clock on the probe error path and module removal.
--
--- Patch [5]: [PATCH treewide 5/5] spi: amlogic-spisg: Make sure clk_init_data is fully initialized --- commit aa4fc6e665f6f8293335c8edd96584e8cdda40c6
Author: Geert Uytterhoeven <[email protected]>
Subject: spi: amlogic-spisg: 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.
drivers/spi/spi-amlogic-spisg.c static int aml_spisg_target_abort(struct spi_controller *ctlr) · line 642
Quoted 13 lines
drivers/spi/spi-amlogic-spisg.c +1
-1@@ -636,7 +636,7 @@ static int aml_spisg_target_abort(struct spi_controller *ctlr)static int aml_spisg_clk_init (struct spisg_device *spisg,void __iomem *base) {struct device *dev = &spisg->pdev->dev; -struct clk_init_data init; +struct clk_init_data init = {};struct clk_divider *div;struct clk_div_table *tbl;char name[32 ];
[Severity: High]
This is a pre-existing issue, but I noticed a severe imbalance in clock prepare/enable counts for the pclk and core clocks.
In aml_spisg_clk_init(), pclk is acquired with devm_clk_get_enabled():
spisg->pclk = devm_clk_get_enabled(dev, "pclk");
But later in the same function, it is manually disabled:
clk_disable_unprepare(spisg->pclk);
Since pclk is managed by devres, won't this manual disable unbalance the clock enable count right from the start?
This pattern is also repeated in the probe error path and remove functions:
drivers/spi/spi-amlogic-spisg.c:aml_spisg_probe() {
...out_clk:
if (spisg->core) clk_disable_unprepare(spisg->core); clk_disable_unprepare(spisg->pclk); return ret; }
Does this cause double-disables and negative enable counts when the devres cleanup runs?
[Severity: High]
This is also a pre-existing issue, but I noticed missing cleanup for runtime PM and the sclk clock.
In aml_spisg_clk_init(), sclk is manually enabled:
clk_prepare_enable(spisg->sclk);
And in aml_spisg_probe(), runtime PM is enabled:
pm_runtime_enable(&spisg->pdev->dev);
However, if devm_request_irq() or spi_register_controller() fails, the out_clk error path simply returns:
drivers/spi/spi-amlogic-spisg.c:aml_spisg_probe() {
...out_clk:
if (spisg->core) clk_disable_unprepare(spisg->core); clk_disable_unprepare(spisg->pclk); return ret; }
Doesn't this leak the sclk enable count and leave runtime PM enabled?
Additionally, aml_spisg_remove() also lacks a pm_runtime_disable() call and skips disabling sclk if the device is not runtime suspended. Should there be explicit teardowns for these in the error and removal paths?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH treewide 5/5] spi: amlogic-spisg: Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoted 11 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.
aml_spisg_clk_init()fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.
Quoted 6 lines
Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes cef9991e04aed330 ("spi: Add Amlogic SPISG driver")Signed-off-by Geert Uytterhoeven <[email protected]>
Re: [PATCH treewide 5/5] spi: amlogic-spisg: Make sure clk_init_data is fully initialized
In reply to Geert UytterhoevenQuoted 36 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.
aml_spisg_clk_init()fills in init.parent_data, and assumes that init.parent_names is NULL. However, the latter in uninitialized, and thus may cause a crash.Make sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Fixes cef9991e04aed330 ("spi: Add Amlogic SPISG driver")Signed-off-by Geert Uytterhoeven<[email protected]>---
Compile-tested only.--- drivers/spi/spi-amlogic-spisg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/spi/spi-amlogic-spisg.c +1
-1@@ -636,7 +636,7 @@ static int aml_spisg_target_abort(struct spi_controller *ctlr)static int aml_spisg_clk_init (struct spisg_device *spisg,void __iomem *base) {struct device *dev = &spisg->pdev->dev; -struct clk_init_data init; +struct clk_init_data init = {};struct clk_divider *div;struct clk_div_table *tbl;char name[32 ];
Mark Brown
maintainerRe: (subset) [PATCH treewide 0/5] clk: Make sure clk_init_data is fully initialized (part 1)
In reply to Geert UytterhoevenQuoted 16 lines · Geert Uytterhoeven
clk: Make sure
clk_init_datais fully initialized (part 1)Hi all,
The
clk_init_datastructure contains three mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. When commitfc0c209c147f35ed("clk: Allow parents to be specified without string names") added the last two methods, this was done in a backwards-compatible way, using a priority-based scheme:
- .name, .ops, .num_parents, and .flags must always be initialized,
- if .num_parents is non-zero, .parent_names must be initialized,
- if .parent_names is NULL, .parent_data must be initialized,
- if .parent_data is NULL, .parent_hws must be initialized and valid.
Quoted 1 line
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.3
Thanks!
[5/5] spi: amlogic-spisg: Make sure clk_init_data is fully initialized
https://git.kernel.org/broonie/spi/c/b2702908ee23
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
Quoted 20 lines · Geert Uytterhoeven
The
clk_init_datastructure contains three mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. When commitfc0c209c147f35ed("clk: Allow parents to be specified without string names") added the last two methods, this was done in a backwards-compatible way, using a priority-based scheme:
- .name, .ops, .num_parents, and .flags must always be initialized,
- if .num_parents is non-zero, .parent_names must be initialized,
- if .parent_names is NULL, .parent_data must be initialized,
- if .parent_data is NULL, .parent_hws must be initialized and valid.However, not initializing all members may cause subtle issues, which are only exposed when
CONFIG_INIT_STACK_ALL_PATTERNorCONFIG_INIT_STACK_NONEis enabled.Hence this series makes sure all members are fully initialized, to fix such bugs, and to avoid future breakage when converting drivers to a different method for specifying the parents.
Quoted 8 lines
This (small) series is part 1, and fixes all cases that I identified to be real bugs:
- The first patch fixes a crash I saw on BeagleBone Black,
- The other patches are only compile-tested.
All patches in this series can be applied independently.Part 2 will be much larger (touching 185 files), and will fix the remaining cases that are currently harmless.
FTR, I split part two in 13 subparts, per subsystem:
- "[PATCH 0/2] ARM/soc: Make sure clk_init_data is fully initialized"
https://lore.kernel.org/[email protected]> - "[PATCH 0/3] ASoC: Make sure clk_init_data is fully initialized" https://lore.kernel.org/[email protected]> - "[PATCH 00/45] clk: Make sure clk_init_data is fully initialized (part two)" https://lore.kernel.org/[email protected]> - "[PATCH 0/2] drm: Make sure clk_init_data is fully initialized" https://lore.kernel.org/[email protected]> - "[PATCH] i2c: bcm2835: Make sure clk_init_data is fully initialized" https://lore.kernel.org/9f82f37e6d6c069cd44326bcd5e5a2a8069a13a9.1787239980.git.geert+renesas@glider.be> - "[PATCH 0/2] iio: Make sure clk_init_data is fully initialized" https://lore.kernel.org/[email protected]> - "[PATCH 0/3] media: Make sure clk_init_data is fully initialized" https://lore.kernel.org/[email protected]> - "[PATCH] MIPS: Alchemy: clock: Make sure clk_init_data is fully" https://lore.kernel.org/3610b51df642abb1fbb39f5bd93fddea43f8f164.1787240060.git.geert+renesas@glider.be> - "[PATCH 0/2] mmc: Make sure clk_init_data is fully initialized" https://lore.kernel.org/[email protected]> - "[PATCH net-next 0/3] net: Make sure clk_init_data is fully initialized" https://lore.kernel.org/[email protected]> - "[PATCH] peci: controller: aspeed: Make sure clk_init_data is fully" https://lore.kernel.org/48aa77c45e109f78ccd806bc3b7bf380c5bc5e71.1787240145.git.geert+renesas@glider.be> - "[PATCH 0/2] phy: Make sure clk_init_data is fully initialized" https://lore.kernel.org/[email protected]> - "[PATCH 0/5] rtc: Make sure clk_init_data is fully initialized" https://lore.kernel.org/[email protected]>
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
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 Torvalds