Skip to contentSkip to conversation

net: Make sure clk_init_data is fully initialized

PATCH Applied Geert Uytterhoeven 2 participants 5 messages Sep 3 – Sep 8

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v2 cover net: 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 networking 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.

Changes compared to v1[2]:
- Add Reviewed-by.

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]
[2] "[PATCH net-next 0/3] net: Make sure clk_init_data is fully

     initialized"
    https://lore.kernel.org/[email protected]

Geert Uytterhoeven (3):
net: macb: Make sure clk_init_data is fully initialized
net: mdio: mux-meson-g12a: Make sure clk_init_data is fully
initialized
net: phy: air_en8811h: Make sure clk_init_data is fully initialized

 drivers/net/ethernet/cadence/macb_main.c | 2 +-
 drivers/net/mdio/mdio-mux-meson-g12a.c   | 2 +-
 drivers/net/phy/air_en8811h.c            | 4 ++--
 3 files changed, 4 insertions(+), 4 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 Torvalds
#1 lore raw

PATCH v2 1/3 net: macb: 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.

v2:
- Add Reviewed-by.

---
 drivers/net/ethernet/cadence/macb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +1 -1
index 76ee4f5060335c4e..2e6a5e93d0cdd5d5 100644
@@ -5375,7 +5375,7 @@ static int fu540_c000_clk_init(struct platform_device *pdev, struct clk **pclk,
 			       struct clk **hclk, struct clk **tx_clk,
 			       struct clk **rx_clk, struct clk **tsu_clk)
 {
-	struct clk_init_data init;
+	struct clk_init_data init = {};
 	int err = 0;
 
 	err = macb_clk_init_dflt(pdev, pclk, hclk, tx_clk, rx_clk, tsu_clk);
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/3 net: mdio: mux-meson-g12a: Make sure clk_init_data is fully initialized

In reply to Geert Uytterhoeven

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.

v2:
- Add Reviewed-by.

---
 drivers/net/mdio/mdio-mux-meson-g12a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/mdio/mdio-mux-meson-g12a.c +1 -1
index 08d6a6c93fb8bf02..e6c9ef3641afa27e 100644
@@ -223,7 +223,7 @@ static int g12a_ephy_glue_clk_register(struct device *dev)
 {
 	struct g12a_mdio_mux *priv = dev_get_drvdata(dev);
 	const char *parent_names[PLL_MUX_NUM_PARENT];
-	struct clk_init_data init;
+	struct clk_init_data init = {};
 	struct g12a_ephy_pll *pll;
 	struct clk_mux *mux;
 	struct clk *clk;
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/3 net: phy: air_en8811h: Make sure clk_init_data is fully initialized

In reply to Geert Uytterhoeven

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.

v2:
- Add Reviewed-by.

---
 drivers/net/phy/air_en8811h.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/air_en8811h.c +2 -2
index 0eeb7b9a4e260bcb..429231949120c7c8 100644
@@ -932,7 +932,7 @@ static const struct clk_ops an8811hb_clk_ops = {
 
 static int an8811hb_clk_provider_setup(struct device *dev, struct clk_hw *hw)
 {
-	struct clk_init_data init;
+	struct clk_init_data init = {};
 	int ret;
 
 	if (!IS_ENABLED(CONFIG_COMMON_CLK))
@@ -1031,7 +1031,7 @@ static const struct clk_ops en8811h_clk_ops = {
 
 static int en8811h_clk_provider_setup(struct device *dev, struct clk_hw *hw)
 {
-	struct clk_init_data init;
+	struct clk_init_data init = {};
 	int ret;
 
 	if (!IS_ENABLED(CONFIG_COMMON_CLK))
Signature · 1 line
2.43.0
#4 lore raw
In reply to Geert Uytterhoeven
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Thu, 3 Sep 2026 11:00:38 +0200 you wrote:

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.

[...]

Here is the summary with links:
- [net-next,v2,1/3] net: macb: Make sure clk_init_data is fully initialized

    https://git.kernel.org/netdev/net-next/c/83e6bb28644a
  - [net-next,v2,2/3] net: mdio: mux-meson-g12a: Make sure clk_init_data is fully initialized
    https://git.kernel.org/netdev/net-next/c/4bee840c7e43
  - [net-next,v2,3/3] net: phy: air_en8811h: Make sure clk_init_data is fully initialized
    https://git.kernel.org/netdev/net-next/c/64adb67e4568

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html