From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Emil Renner Berthing <kernel@esmil.dk>,
Hal Feng <hal.feng@starfivetech.com>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Wentao Liang <vulab@iscas.ac.cn>,
Dominique Belhachemi <db@domibel.de>,
Michal Wilczynski <m.wilczynski@samsung.com>,
Joshua Peisach <jpeisach@ubuntu.com>,
Xingyu Wu <xingyu.wu@starfivetech.com>,
Conor Dooley <conor.dooley@microchip.com>,
Palmer Dabbelt <palmer@rivosinc.com>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 04/10] clk: starfive: jh7110: Duplicate top clock bulk arrays per device
Date: Fri, 27 Nov 2026 19:25:28 +0000 [thread overview]
Message-ID: <20261127192620.3443537-5-lee@kernel.org> (raw)
In-Reply-To: <20261127192620.3443537-1-lee@kernel.org>
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@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
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
next prev parent reply other threads:[~2026-11-27 19:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
2026-11-27 19:25 ` [PATCH 01/10] clk: ti: fapll: Fix output clock array allocation and bounds check Lee Jones
2026-11-27 19:36 ` sashiko-bot
2026-11-27 19:25 ` [PATCH 02/10] clk: tegra: bpmp: Drop manual clock unregister on provider failure Lee Jones
2026-11-27 19:36 ` sashiko-bot
2026-11-27 19:25 ` [PATCH 03/10] clk: starfive: jh7110-sys: Use devres for PLL0 clock and notifier Lee Jones
2026-11-27 19:25 ` Lee Jones [this message]
2026-11-27 19:25 ` [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier Lee Jones
2026-11-27 19:33 ` sashiko-bot
2026-11-27 19:25 ` [PATCH 06/10] clk: tegra: bpmp: Skip ERR_PTR entries in tegra_bpmp_clk_of_xlate() Lee Jones
2026-11-27 19:25 ` [PATCH 07/10] clk: rp1: Propagate determine_rate() return value for PLL dividers Lee Jones
2026-11-27 19:25 ` [PATCH 08/10] clk: rp1: Reference secondary PLL divider clk_hw in parent tables Lee Jones
2026-11-27 19:25 ` [PATCH 09/10] clk: keystone: sci-clk: Check allocation failure before copying clock array Lee Jones
2026-11-27 19:25 ` [PATCH 10/10] clk: versatile: icst: Check kasprintf() and put parent node on error Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127192620.3443537-5-lee@kernel.org \
--to=lee@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=conor.dooley@microchip.com \
--cc=db@domibel.de \
--cc=hal.feng@starfivetech.com \
--cc=jbrunet+clk@baylibre.com \
--cc=jpeisach@ubuntu.com \
--cc=kernel@esmil.dk \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.wilczynski@samsung.com \
--cc=palmer@rivosinc.com \
--cc=sboyd@kernel.org \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
--cc=xingyu.wu@starfivetech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox