[PATCH 04/10] clk: starfive: jh7110: Duplicate top clock bulk arrays per device

From: Lee Jones

Date: Fri Nov 27 2026 - 14:27:04 EST


Both the JH7110 ISP and Video-Output clock drivers point top->top_clks
directly at static global struct clk_bulk_data arrays and pass them to
devm_clk_bulk_get(), mutating shared global state in place across probes
or unbind/rebind cycles.

Mark the template arrays const and allocate per-device copies with
devm_kmemdup_array().

Fixes: 81279f5d0812 ("clk: starfive: Add StarFive JH7110 Image-Signal-Process clock driver")
Fixes: dae5448a327e ("clk: starfive: Add StarFive JH7110 Video-Output clock driver")
Closes: https://sashiko.dev/#/bug/linux-ac62c6ac-f9af-4289-9154-e1129a2f6139
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/clk/starfive/clk-starfive-jh7110-isp.c | 9 +++++++--
drivers/clk/starfive/clk-starfive-jh7110-vout.c | 9 +++++++--
2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/starfive/clk-starfive-jh7110-isp.c b/drivers/clk/starfive/clk-starfive-jh7110-isp.c
index d39ce4a2a8e9..9395de01d42b 100644
--- a/drivers/clk/starfive/clk-starfive-jh7110-isp.c
+++ b/drivers/clk/starfive/clk-starfive-jh7110-isp.c
@@ -23,7 +23,7 @@
#define JH7110_ISPCLK_DVP_CLK (JH7110_ISPCLK_END + 3)
#define JH7110_ISPCLK_EXT_END (JH7110_ISPCLK_END + 4)

-static struct clk_bulk_data jh7110_isp_top_clks[] = {
+static const struct clk_bulk_data jh7110_isp_top_clks[] = {
{ .id = "isp_top_core" },
{ .id = "isp_top_axi" }
};
@@ -119,8 +119,13 @@ static int jh7110_ispcrg_probe(struct platform_device *pdev)
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);

- top->top_clks = jh7110_isp_top_clks;
top->top_clks_num = ARRAY_SIZE(jh7110_isp_top_clks);
+ top->top_clks = devm_kmemdup_array(priv->dev, jh7110_isp_top_clks,
+ top->top_clks_num,
+ sizeof(*top->top_clks), GFP_KERNEL);
+ if (!top->top_clks)
+ return -ENOMEM;
+
ret = devm_clk_bulk_get(priv->dev, top->top_clks_num, top->top_clks);
if (ret)
return dev_err_probe(priv->dev, ret, "failed to get main clocks\n");
diff --git a/drivers/clk/starfive/clk-starfive-jh7110-vout.c b/drivers/clk/starfive/clk-starfive-jh7110-vout.c
index d4181cce9c15..8b4dbae372ee 100644
--- a/drivers/clk/starfive/clk-starfive-jh7110-vout.c
+++ b/drivers/clk/starfive/clk-starfive-jh7110-vout.c
@@ -25,7 +25,7 @@
#define JH7110_VOUTCLK_HDMITX0_PIXELCLK (JH7110_VOUTCLK_END + 5)
#define JH7110_VOUTCLK_EXT_END (JH7110_VOUTCLK_END + 6)

-static struct clk_bulk_data jh7110_vout_top_clks[] = {
+static const struct clk_bulk_data jh7110_vout_top_clks[] = {
{ .id = "vout_src" },
{ .id = "vout_top_ahb" }
};
@@ -126,8 +126,13 @@ static int jh7110_voutcrg_probe(struct platform_device *pdev)
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);

- top->top_clks = jh7110_vout_top_clks;
top->top_clks_num = ARRAY_SIZE(jh7110_vout_top_clks);
+ top->top_clks = devm_kmemdup_array(priv->dev, jh7110_vout_top_clks,
+ top->top_clks_num,
+ sizeof(*top->top_clks), GFP_KERNEL);
+ if (!top->top_clks)
+ return -ENOMEM;
+
ret = devm_clk_bulk_get(priv->dev, top->top_clks_num, top->top_clks);
if (ret)
return dev_err_probe(priv->dev, ret, "failed to get top clocks\n");
--
2.56.1.839.g22a8290db9-goog