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>,
Xingyu Wu <xingyu.wu@starfivetech.com>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 03/10] clk: starfive: jh7110-sys: Use devres for PLL0 clock and notifier
Date: Fri, 27 Nov 2026 19:25:27 +0000 [thread overview]
Message-ID: <20261127192620.3443537-4-lee@kernel.org> (raw)
In-Reply-To: <20261127192620.3443537-1-lee@kernel.org>
jh7110_syscrg_probe() allocates priv with devm_kzalloc_flex() but
acquires pll0_out with clk_get() and registers &priv->pll_clk_nb with
unmanaged clk_notifier_register(). If any subsequent step in probe
fails, devres frees priv while the notifier stays registered on
pll0_out, resulting in a use-after-free on the next rate change and a
leaked clock reference.
Use devm_clk_get() and devm_clk_notifier_register() so both the notifier
and clock reference are released automatically in LIFO order before priv
is freed.
Fixes: 538d5477b252 ("clk: starfive: jh7110-sys: Add notifier for PLL0 clock")
Closes: https://sashiko.dev/#/bug/linux-43575972-eb4c-4bf9-8cfe-cef64199b7e2
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/starfive/clk-starfive-jh7110-sys.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/starfive/clk-starfive-jh7110-sys.c b/drivers/clk/starfive/clk-starfive-jh7110-sys.c
index 44766b094b60..02ecf32fffdc 100644
--- a/drivers/clk/starfive/clk-starfive-jh7110-sys.c
+++ b/drivers/clk/starfive/clk-starfive-jh7110-sys.c
@@ -422,7 +422,7 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)
return PTR_ERR(priv->base);
/* Use fixed factor clocks if can not get the PLL clocks from DTS */
- pllclk = clk_get(priv->dev, "pll0_out");
+ pllclk = devm_clk_get(priv->dev, "pll0_out");
if (IS_ERR(pllclk)) {
/* 24MHz -> 1000.0MHz */
priv->pll[0] = devm_clk_hw_register_fixed_factor(priv->dev, "pll0_out",
@@ -431,7 +431,8 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)
return PTR_ERR(priv->pll[0]);
} else {
priv->pll_clk_nb.notifier_call = jh7110_pll0_clk_notifier_cb;
- ret = clk_notifier_register(pllclk, &priv->pll_clk_nb);
+ ret = devm_clk_notifier_register(priv->dev, pllclk,
+ &priv->pll_clk_nb);
if (ret)
return ret;
priv->pll[0] = NULL;
--
2.56.1.839.g22a8290db9-goog
next prev parent reply other threads:[~2026-11-27 19:26 UTC|newest]
Thread overview: 11+ 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:25 ` [PATCH 02/10] clk: tegra: bpmp: Drop manual clock unregister on provider failure Lee Jones
2026-11-27 19:25 ` Lee Jones [this message]
2026-11-27 19:25 ` [PATCH 04/10] clk: starfive: jh7110: Duplicate top clock bulk arrays per device Lee Jones
2026-11-27 19:25 ` [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier Lee Jones
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-4-lee@kernel.org \
--to=lee@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=hal.feng@starfivetech.com \
--cc=jbrunet+clk@baylibre.com \
--cc=kernel@esmil.dk \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=stable@vger.kernel.org \
--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