* [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2)
@ 2026-11-27 19:25 Lee Jones
2026-11-27 19:25 ` [PATCH 01/10] clk: ti: fapll: Fix output clock array allocation and bounds check Lee Jones
` (9 more replies)
0 siblings, 10 replies; 14+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Heiko Stuebner, linux-arm-kernel, linux-rockchip
Cc: linux-kernel, Thomas Richard (TI), Andrea della Porta,
Brian Masney, Conor Dooley, Dominique Belhachemi, Doug Anderson,
Emil Renner Berthing, Florian Fainelli, Hal Feng, Jerome Brunet,
Jonathan Hunter, Joshua Peisach, Linus Walleij, linux-clk,
linux-omap, linux-tegra, Michael Turquette, Michal Wilczynski,
Naushir Patuck, Nishanth Menon, Palmer Dabbelt, Prashant Gaikwad,
Rob Herring, Rosen Penev, Santosh Shilimkar, Stephen Boyd,
Tero Kristo, Thierry Reding, Thomas Abraham, Timo Alho,
Tony Lindgren, Wentao Liang, Xingyu Wu
These issues were reported by Sashiko.
This is batch 2 of Common Clock Framework fixes, based on clk/clk-next.
It addresses output array OOB writes in ti/fapll, ERR_PTR dereferences
and double-unregister in tegra/bpmp, notifier UAFs and global array
mutation in starfive/jh7110 and rockchip/cpu, rate and parent lookup
bugs in rp1, and allocation error handling in sci-clk and icst.
Cc: "Thomas Richard (TI)" <thomas.richard@bootlin.com>
Cc: Andrea della Porta <andrea.porta@suse.com>
Cc: Brian Masney <bmasney+clk@redhat.com>
Cc: Conor Dooley <conor.dooley@microchip.com>
Cc: Dominique Belhachemi <db@domibel.de>
Cc: Doug Anderson <dianders@chromium.org>
Cc: Emil Renner Berthing <kernel@esmil.dk>
Cc: Florian Fainelli <florian.fainelli@broadcom.com>
Cc: Hal Feng <hal.feng@starfivetech.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Jerome Brunet <jbrunet+clk@baylibre.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Joshua Peisach <jpeisach@ubuntu.com>
Cc: Linus Walleij <linusw@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-clk@vger.kernel.org
Cc: linux-omap@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-tegra@vger.kernel.org
Cc: Michael Turquette <mturquette@linaro.org>
Cc: Michal Wilczynski <m.wilczynski@samsung.com>
Cc: Naushir Patuck <naush@raspberrypi.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Palmer Dabbelt <palmer@rivosinc.com>
Cc: Prashant Gaikwad <pgaikwad@nvidia.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Rosen Penev <rosenp@gmail.com>
Cc: Santosh Shilimkar <ssantosh@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Tero Kristo <kristo@kernel.org>
Cc: Thierry Reding <thierry.reding@kernel.org>
Cc: Thomas Abraham <thomas.ab@samsung.com>
Cc: Timo Alho <talho@nvidia.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Wentao Liang <vulab@iscas.ac.cn>
Cc: Xingyu Wu <xingyu.wu@starfivetech.com>
Lee Jones (10):
clk: ti: fapll: Fix output clock array allocation and bounds check
clk: tegra: bpmp: Drop manual clock unregister on provider failure
clk: starfive: jh7110-sys: Use devres for PLL0 clock and notifier
clk: starfive: jh7110: Duplicate top clock bulk arrays per device
clk: rockchip: cpu: Allocate rate_table before registering notifier
clk: tegra: bpmp: Skip ERR_PTR entries in tegra_bpmp_clk_of_xlate()
clk: rp1: Propagate determine_rate() return value for PLL dividers
clk: rp1: Reference secondary PLL divider clk_hw in parent tables
clk: keystone: sci-clk: Check allocation failure before copying clock
array
clk: versatile: icst: Check kasprintf() and put parent node on error
drivers/clk/clk-rp1.c | 32 +++++++++----------
drivers/clk/keystone/sci-clk.c | 8 +++--
drivers/clk/rockchip/clk-cpu.c | 26 +++++++--------
.../clk/starfive/clk-starfive-jh7110-isp.c | 9 ++++--
.../clk/starfive/clk-starfive-jh7110-sys.c | 5 +--
.../clk/starfive/clk-starfive-jh7110-vout.c | 9 ++++--
drivers/clk/tegra/clk-bpmp.c | 14 +-------
drivers/clk/ti/fapll.c | 13 +++++---
drivers/clk/versatile/clk-icst.c | 5 +++
9 files changed, 66 insertions(+), 55 deletions(-)
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 01/10] clk: ti: fapll: Fix output clock array allocation and bounds check
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 ` 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
` (8 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Tero Kristo, Stephen Boyd, Brian Masney, Jerome Brunet,
Tony Lindgren, Michael Turquette, linux-omap, linux-clk,
linux-kernel
Cc: stable
ti_fapll_setup() allocates fd->outputs.clks as
sizeof(struct clk *) * MAX_FAPLL_OUTPUTS + 1, adding a single byte
rather than an extra pointer slot for the 1-based child synthesisers
stored at indices 1..MAX_FAPLL_OUTPUTS. It also reads output_instance
into a signed int via of_property_read_u32_index() and indexes
fd->outputs.clks[output_instance] without bounds validation, allowing
out-of-bounds heap writes.
Allocate MAX_FAPLL_OUTPUTS + 1 pointer slots with kzalloc_objs(), store
output_instance as u32, and skip entries exceeding MAX_FAPLL_OUTPUTS.
Fixes: 163152cbbe32 ("clk: ti: Add support for FAPLL on dm816x")
Closes: https://sashiko.dev/#/bug/linux-48a97add-8ee5-49f5-b05c-925006d9ec42
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/ti/fapll.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
index 7d6a4dd4fc8c..d5e95e6489cd 100644
--- a/drivers/clk/ti/fapll.c
+++ b/drivers/clk/ti/fapll.c
@@ -549,9 +549,8 @@ static void __init ti_fapll_setup(struct device_node *node)
if (!fd)
return;
- fd->outputs.clks = kzalloc(sizeof(struct clk *) *
- MAX_FAPLL_OUTPUTS + 1,
- GFP_KERNEL);
+ fd->outputs.clks = kzalloc_objs(*fd->outputs.clks,
+ MAX_FAPLL_OUTPUTS + 1);
if (!fd->outputs.clks)
goto free;
@@ -614,7 +613,7 @@ static void __init ti_fapll_setup(struct device_node *node)
const char *output_name;
void __iomem *freq, *div;
struct clk *synth_clk;
- int output_instance;
+ u32 output_instance;
u32 v;
if (of_property_read_string_index(node, "clock-output-names",
@@ -625,6 +624,12 @@ static void __init ti_fapll_setup(struct device_node *node)
&output_instance))
output_instance = i;
+ if (output_instance > MAX_FAPLL_OUTPUTS) {
+ pr_err("%pOFn invalid output_instance %u\n",
+ node, output_instance);
+ continue;
+ }
+
freq = fd->base + (output_instance * 8);
div = freq + 4;
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 02/10] clk: tegra: bpmp: Drop manual clock unregister on provider failure
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 ` 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
` (7 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Prashant Gaikwad, Stephen Boyd, Brian Masney, Jerome Brunet,
Thierry Reding, Jonathan Hunter, Rosen Penev, linux-clk,
linux-tegra, linux-kernel
Cc: stable
tegra_bpmp_clk_register() registers every clock with
devm_clk_hw_register(), and tegra_bpmp_register_clocks_one() records
ERR_PTR values in bpmp->clocks[i] whenever an individual clock fails to
register. If of_clk_add_hw_provider() fails,
tegra_bpmp_unregister_clocks() unconditionally dereferences
bpmp->clocks[i] and calls clk_hw_unregister(), crashing on any error
pointer and double-unregistering clocks when devres subsequently unwinds
on probe failure.
Remove tegra_bpmp_unregister_clocks() and rely on devres to unregister
the clocks cleanly.
Fixes: ca6f2796eef7 ("clk: tegra: Add BPMP clock driver")
Closes: https://sashiko.dev/#/bug/linux-e3e9ccfe-87c7-4de5-b6bb-9b6968df7cc4
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/tegra/clk-bpmp.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/drivers/clk/tegra/clk-bpmp.c b/drivers/clk/tegra/clk-bpmp.c
index 3649324e2e1f..e4b4f3eec777 100644
--- a/drivers/clk/tegra/clk-bpmp.c
+++ b/drivers/clk/tegra/clk-bpmp.c
@@ -648,14 +648,6 @@ static int tegra_bpmp_register_clocks(struct tegra_bpmp *bpmp,
return 0;
}
-static void tegra_bpmp_unregister_clocks(struct tegra_bpmp *bpmp)
-{
- unsigned int i;
-
- for (i = 0; i < bpmp->num_clocks; i++)
- clk_hw_unregister(&bpmp->clocks[i]->hw);
-}
-
static struct clk_hw *tegra_bpmp_clk_of_xlate(struct of_phandle_args *clkspec,
void *data)
{
@@ -696,10 +688,6 @@ int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp)
err = of_clk_add_hw_provider(bpmp->dev->of_node,
tegra_bpmp_clk_of_xlate,
bpmp);
- if (err < 0) {
- tegra_bpmp_unregister_clocks(bpmp);
- goto free;
- }
free:
kfree(clocks);
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 03/10] clk: starfive: jh7110-sys: Use devres for PLL0 clock and notifier
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
2026-11-27 19:25 ` [PATCH 04/10] clk: starfive: jh7110: Duplicate top clock bulk arrays per device Lee Jones
` (6 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Emil Renner Berthing, Hal Feng, Stephen Boyd, Brian Masney,
Jerome Brunet, Xingyu Wu, linux-clk, linux-kernel
Cc: stable
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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 04/10] clk: starfive: jh7110: Duplicate top clock bulk arrays per device
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
` (2 preceding siblings ...)
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
2026-11-27 19:25 ` [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier Lee Jones
` (5 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Emil Renner Berthing, Hal Feng, Stephen Boyd, Brian Masney,
Jerome Brunet, Wentao Liang, Dominique Belhachemi,
Michal Wilczynski, Joshua Peisach, Xingyu Wu, Conor Dooley,
Palmer Dabbelt, linux-clk, linux-kernel
Cc: stable
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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
` (3 preceding siblings ...)
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 ` 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
` (4 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Stephen Boyd, Brian Masney, Jerome Brunet, Heiko Stuebner,
Thomas Abraham, Doug Anderson, linux-clk, linux-arm-kernel,
linux-rockchip, linux-kernel
Cc: stable
rockchip_clk_register_cpuclk() registers cpuclk->clk_nb before
allocating cpuclk->rate_table, and on clk_register() failure frees
cpuclk->rate_table before unregistering the notifier. A concurrent
parent rate change can therefore observe a NULL rate_table while
rate_count is already non-zero, or dereference the freed rate_table
before clk_notifier_unregister() completes.
Allocate and populate cpuclk->rate_table before calling
clk_notifier_register(), and reverse the error-path teardown so the
notifier is unregistered before cpuclk->rate_table is freed.
Fixes: f6fba5f6967d ("clk: rockchip: add new clock-type for the cpuclk")
Closes: https://sashiko.dev/#/bug/linux-c0f18cf6-69e2-4cc3-8b2b-7b25245ccd06
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/rockchip/clk-cpu.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c
index eb6b8b878e4d..27d5b6f6987d 100644
--- a/drivers/clk/rockchip/clk-cpu.c
+++ b/drivers/clk/rockchip/clk-cpu.c
@@ -360,36 +360,36 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
goto free_alt_parent;
}
- ret = clk_notifier_register(clk, &cpuclk->clk_nb);
- if (ret) {
- pr_err("%s: failed to register clock notifier for %s\n",
- __func__, name);
- goto free_alt_parent;
- }
-
if (nrates > 0) {
- cpuclk->rate_count = nrates;
cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates),
GFP_KERNEL);
if (!cpuclk->rate_table) {
ret = -ENOMEM;
- goto unregister_notifier;
+ goto free_alt_parent;
}
+ cpuclk->rate_count = nrates;
+ }
+
+ ret = clk_notifier_register(clk, &cpuclk->clk_nb);
+ if (ret) {
+ pr_err("%s: failed to register clock notifier for %s\n",
+ __func__, name);
+ goto free_rate_table;
}
cclk = clk_register(NULL, &cpuclk->hw);
if (IS_ERR(cclk)) {
- pr_err("%s: could not register cpuclk %s\n", __func__, name);
+ pr_err("%s: could not register cpuclk %s\n", __func__, name);
ret = PTR_ERR(cclk);
- goto free_rate_table;
+ goto unregister_notifier;
}
return cclk;
-free_rate_table:
- kfree(cpuclk->rate_table);
unregister_notifier:
clk_notifier_unregister(clk, &cpuclk->clk_nb);
+free_rate_table:
+ kfree(cpuclk->rate_table);
free_alt_parent:
clk_disable_unprepare(cpuclk->alt_parent);
free_cpuclk:
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 06/10] clk: tegra: bpmp: Skip ERR_PTR entries in tegra_bpmp_clk_of_xlate()
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
` (4 preceding siblings ...)
2026-11-27 19:25 ` [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier Lee Jones
@ 2026-11-27 19:25 ` Lee Jones
2026-11-27 19:25 ` [PATCH 07/10] clk: rp1: Propagate determine_rate() return value for PLL dividers Lee Jones
` (3 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Prashant Gaikwad, Stephen Boyd, Brian Masney, Jerome Brunet,
Thierry Reding, Jonathan Hunter, Rosen Penev, Timo Alho,
linux-clk, linux-tegra, linux-kernel
Cc: stable
tegra_bpmp_register_clocks_one() intentionally stores ERR_PTR values in
bpmp->clocks[i] when registering a clock fails. However,
tegra_bpmp_clk_of_xlate() only checks for NULL before dereferencing
clk->id, crashing on any failed clock slot.
Use IS_ERR_OR_NULL() when skipping unpopulated clock entries.
Fixes: 2db12b15c6f3 ("clk: tegra: Register clocks from root to leaf")
Closes: https://sashiko.dev/#/bug/linux-3d54138a-c3d2-4466-952a-f7e44259adfe
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/tegra/clk-bpmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/tegra/clk-bpmp.c b/drivers/clk/tegra/clk-bpmp.c
index e4b4f3eec777..7cbdd7797623 100644
--- a/drivers/clk/tegra/clk-bpmp.c
+++ b/drivers/clk/tegra/clk-bpmp.c
@@ -657,7 +657,7 @@ static struct clk_hw *tegra_bpmp_clk_of_xlate(struct of_phandle_args *clkspec,
for (i = 0; i < bpmp->num_clocks; i++) {
struct tegra_bpmp_clk *clk = bpmp->clocks[i];
- if (!clk)
+ if (IS_ERR_OR_NULL(clk))
continue;
if (clk->id == id)
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 07/10] clk: rp1: Propagate determine_rate() return value for PLL dividers
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
` (5 preceding siblings ...)
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 ` Lee Jones
2026-11-27 19:25 ` [PATCH 08/10] clk: rp1: Reference secondary PLL divider clk_hw in parent tables Lee Jones
` (2 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Andrea della Porta, Stephen Boyd, Brian Masney,
Jerome Brunet, Naushir Patuck, Florian Fainelli, linux-clk,
linux-kernel
Cc: stable
rp1_pll_divider_determine_rate() assigns the return value of
clk_divider_ops.determine_rate() to req->rate and always returns 0.
Because determine_rate() updates req->rate in place and returns 0 on
success or a negative error code on failure, every call overwrites
req->rate with zero or a cast errno and discards errors.
Return the result of clk_divider_ops.determine_rate() directly.
Fixes: 41c9570e4178 ("clk: rp1: convert from round_rate() to determine_rate()")
Closes: https://sashiko.dev/#/bug/linux-ce521c83-c4f2-4949-91e9-1e9702c8bbd1
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/clk-rp1.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/clk/clk-rp1.c b/drivers/clk/clk-rp1.c
index 1dd276dd2bb3..cfa7cbefad2e 100644
--- a/drivers/clk/clk-rp1.c
+++ b/drivers/clk/clk-rp1.c
@@ -770,9 +770,7 @@ static unsigned long rp1_pll_divider_recalc_rate(struct clk_hw *hw,
static int rp1_pll_divider_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
- req->rate = clk_divider_ops.determine_rate(hw, req);
-
- return 0;
+ return clk_divider_ops.determine_rate(hw, req);
}
static int rp1_clock_is_on(struct clk_hw *hw)
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 08/10] clk: rp1: Reference secondary PLL divider clk_hw in parent tables
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
` (6 preceding siblings ...)
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 ` 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
9 siblings, 0 replies; 14+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Andrea della Porta, Stephen Boyd, Brian Masney,
Jerome Brunet, Naushir Patuck, Florian Fainelli, linux-clk,
linux-kernel
Cc: stable
rp1_register_pll_divider() registers &desc->div.hw rather than
&desc->hw, leaving desc->hw.core NULL for the secondary PLL dividers
pll_sys_sec_desc, pll_video_sec_desc, and pll_audio_sec_desc. Fourteen
clock parent table entries still reference &pll_*_sec_desc.hw instead of
&pll_*_sec_desc.div.hw, causing parent resolution to fail for those
clocks.
Point all fourteen parent entries at .div.hw, matching clk_eth_parents.
Fixes: a7713a7dd159 ("clk: rp1: Implement remaining clock tree")
Closes: https://sashiko.dev/#/bug/linux-4497e5e9-4f3a-4398-8f6a-f2d72a2b61eb
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/clk-rp1.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/clk/clk-rp1.c b/drivers/clk/clk-rp1.c
index cfa7cbefad2e..d5d94d699829 100644
--- a/drivers/clk/clk-rp1.c
+++ b/drivers/clk/clk-rp1.c
@@ -1419,7 +1419,7 @@ static struct rp1_clk_desc pll_video_sec_desc = REGISTER_PLL_DIV(
static const struct clk_parent_data clk_eth_tsu_parents[] = {
{ .index = 0 },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
{ .index = -1 },
{ .index = -1 },
{ .index = -1 },
@@ -1450,7 +1450,7 @@ static struct rp1_clk_desc clk_eth_tsu_desc = REGISTER_CLK(
static const struct clk_parent_data clk_eth_parents[] = {
{ .hw = &pll_sys_sec_desc.div.hw },
{ .hw = &pll_sys_desc.hw },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
};
static struct rp1_clk_desc clk_eth_desc = REGISTER_CLK(
@@ -1651,7 +1651,7 @@ static struct rp1_clk_desc clk_uart_desc = REGISTER_CLK(
static const struct clk_parent_data clk_pwm0_parents[] = {
{ .index = -1 },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
{ .index = 0 },
};
@@ -1677,7 +1677,7 @@ static struct rp1_clk_desc clk_pwm0_desc = REGISTER_CLK(
static const struct clk_parent_data clk_pwm1_parents[] = {
{ .index = -1 },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
{ .index = 0 },
};
@@ -1705,7 +1705,7 @@ static const struct clk_parent_data clk_audio_in_parents[] = {
{ .index = -1 },
{ .index = -1 },
{ .index = -1 },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
{ .index = 0 },
};
@@ -1731,7 +1731,7 @@ static struct rp1_clk_desc clk_audio_in_desc = REGISTER_CLK(
static const struct clk_parent_data clk_audio_out_parents[] = {
{ .index = -1 },
{ .index = -1 },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
{ .index = 0 },
};
@@ -1757,7 +1757,7 @@ static struct rp1_clk_desc clk_audio_out_desc = REGISTER_CLK(
static const struct clk_parent_data clk_i2s_parents[] = {
{ .index = 0 },
{ .hw = &pll_audio_desc.hw },
- { .hw = &pll_audio_sec_desc.hw },
+ { .hw = &pll_audio_sec_desc.div.hw },
};
static struct rp1_clk_desc clk_i2s_desc = REGISTER_CLK(
@@ -1879,7 +1879,7 @@ static struct rp1_clk_desc clk_sdio_alt_src_desc = REGISTER_CLK(
static const struct clk_parent_data clk_dpi_parents[] = {
{ .hw = &pll_sys_desc.hw },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
{ .hw = &pll_video_desc.hw },
{ .index = -1 },
{ .index = -1 },
@@ -2015,7 +2015,7 @@ static struct rp1_clk_desc clksrc_mipi1_dsi_byteclk_desc = REGISTER_CLK(
static const struct clk_parent_data clk_mipi0_dpi_parents[] = {
{ .hw = &pll_sys_desc.hw },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
{ .hw = &pll_video_desc.hw },
{ .hw = &clksrc_mipi0_dsi_byteclk_desc.hw },
{ .index = -1 },
@@ -2046,7 +2046,7 @@ static struct rp1_clk_desc clk_mipi0_dpi_desc = REGISTER_CLK(
static const struct clk_parent_data clk_mipi1_dpi_parents[] = {
{ .hw = &pll_sys_desc.hw },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
{ .hw = &pll_video_desc.hw },
{ .hw = &clksrc_mipi1_dsi_byteclk_desc.hw },
{ .index = -1 },
@@ -2082,7 +2082,7 @@ static const struct clk_parent_data clk_gp2_parents[] = {
{ .index = -1 },
{ .index = -1 },
{ .index = -1 },
- { .hw = &pll_sys_sec_desc.hw },
+ { .hw = &pll_sys_sec_desc.div.hw },
{ .index = -1 },
{ .hw = &pll_video_desc.hw },
{ .hw = &clk_audio_in_desc.hw },
@@ -2163,7 +2163,7 @@ static const struct clk_parent_data clk_gp4_parents[] = {
{ .index = -1 },
{ .index = -1 },
{ .index = -1 },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
{ .index = -1 },
{ .index = -1 },
{ .index = -1 },
@@ -2197,7 +2197,7 @@ static struct rp1_clk_desc clk_gp4_desc = REGISTER_CLK(
static const struct clk_parent_data clk_vec_parents[] = {
{ .hw = &pll_sys_pri_ph_desc.hw },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
{ .hw = &pll_video_desc.hw },
{ .index = -1 },
{ .index = -1 },
@@ -2233,7 +2233,7 @@ static const struct clk_parent_data clk_gp5_parents[] = {
{ .index = -1 },
{ .index = -1 },
{ .index = -1 },
- { .hw = &pll_video_sec_desc.hw },
+ { .hw = &pll_video_sec_desc.div.hw },
{ .hw = &clk_eth_tsu_desc.hw },
{ .index = -1 },
{ .hw = &clk_vec_desc.hw },
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 09/10] clk: keystone: sci-clk: Check allocation failure before copying clock array
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
` (7 preceding siblings ...)
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 ` Lee Jones
2026-11-27 19:25 ` [PATCH 10/10] clk: versatile: icst: Check kasprintf() and put parent node on error Lee Jones
9 siblings, 0 replies; 14+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Nishanth Menon, Tero Kristo, Santosh Shilimkar, Stephen Boyd,
Brian Masney, Jerome Brunet, Thomas Richard (TI),
linux-arm-kernel, linux-kernel, linux-clk
Cc: stable
ti_sci_scan_clocks_from_fw() calls devm_kmalloc_objs() without checking
for NULL before passing tmp_clks into memcpy(), and invokes memcpy()
with a NULL source pointer on the initial iteration when max_clks is
zero.
Return -ENOMEM if devm_kmalloc_objs() fails, and only copy and free the
previous array when max_clks is non-zero.
Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")
Closes: https://sashiko.dev/#/bug/linux-4e2ecf16-17f1-4188-880c-c714a1bf588c
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/keystone/sci-clk.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c
index 967f77900358..4cb1299cd49e 100644
--- a/drivers/clk/keystone/sci-clk.c
+++ b/drivers/clk/keystone/sci-clk.c
@@ -495,9 +495,13 @@ static int ti_sci_scan_clocks_from_fw(struct sci_clk_provider *provider)
if (num_clks == max_clks) {
tmp_clks = devm_kmalloc_objs(dev, sci_clk,
max_clks + 64);
- memcpy(tmp_clks, clks, max_clks * sizeof(sci_clk));
- if (max_clks)
+ if (!tmp_clks)
+ return -ENOMEM;
+ if (max_clks) {
+ memcpy(tmp_clks, clks,
+ max_clks * sizeof(sci_clk));
devm_kfree(dev, clks);
+ }
max_clks += 64;
clks = tmp_clks;
}
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 10/10] clk: versatile: icst: Check kasprintf() and put parent node on error
2026-11-27 19:25 [PATCH 00/10] clk: Fix OOB writes, UAFs, ERR_PTR dereferences, and rate-calc bugs (batch 2) Lee Jones
` (8 preceding siblings ...)
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 ` Lee Jones
9 siblings, 0 replies; 14+ messages in thread
From: Lee Jones @ 2026-11-27 19:25 UTC (permalink / raw)
To: lee, Linus Walleij, Stephen Boyd, Brian Masney, Jerome Brunet,
Rob Herring, linux-arm-kernel, linux-clk, linux-kernel
Cc: stable
of_syscon_icst_setup() does not check the return value of kasprintf()
before passing name into icst_clk_setup(), causing registration to fail
with -ENOMEM after redundant allocations and logging a NULL name while
leaking the parent device node reference. The IS_ERR(regclk) error path
also omits of_node_put().
Release the parent node and return early when kasprintf() fails, and
release the parent node when icst_clk_setup() returns an error.
Fixes: 1b2189f3aa50 ("clk: versatile: clk-icst: Ensure clock names are unique")
Fixes: d430819d69a5 ("clk: versatile-icst: add device tree support")
Closes: https://sashiko.dev/#/bug/linux-e1f9fcba-856e-41f5-ba69-bf159007e2af
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/clk/versatile/clk-icst.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/clk/versatile/clk-icst.c b/drivers/clk/versatile/clk-icst.c
index e9c7353aa5d5..10cb34a3e8ea 100644
--- a/drivers/clk/versatile/clk-icst.c
+++ b/drivers/clk/versatile/clk-icst.c
@@ -566,11 +566,16 @@ static void __init of_syscon_icst_setup(struct device_node *np)
/* Parent clock name is not the same as node parent */
parent_name = of_clk_get_parent_name(np, 0);
name = kasprintf(GFP_KERNEL, "%pOFP", np);
+ if (!name) {
+ of_node_put(parent);
+ return;
+ }
regclk = icst_clk_setup(NULL, &icst_desc, name, parent_name, map, ctype);
if (IS_ERR(regclk)) {
pr_err("error setting up syscon ICST clock %s\n", name);
kfree(name);
+ of_node_put(parent);
return;
}
of_clk_add_provider(np, of_clk_src_simple_get, regclk);
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier
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
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-27 19:33 UTC (permalink / raw)
To: Lee Jones, linux-clk
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] clk: rockchip: leaked notifier in
rockchip_clk_register_cpuclk_multi_pll() [1]
--
commit 87431f3421888170ed6b1c77970113743924cab9
Author: Lee Jones <lee@kernel.org>
clk: rockchip: cpu: Allocate rate_table before registering notifier
This commit allocates and populates cpuclk->rate_table before calling
clk_notifier_register() in rockchip_clk_register_cpuclk(), and reverses the
error teardown order so the notifier is unregistered before rate_table is
freed.
> diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c
> index eb6b8b878e4db..27d5b6f6987db 100644
> --- a/drivers/clk/rockchip/clk-cpu.c
> +++ b/drivers/clk/rockchip/clk-cpu.c
> @@ -360,36 +360,36 @@ struct clk *rockchip_clk_register_cpuclk(const char *name,
> goto free_alt_parent;
> }
>
> - ret = clk_notifier_register(clk, &cpuclk->clk_nb);
> - if (ret) {
> - pr_err("%s: failed to register clock notifier for %s\n",
> - __func__, name);
> - goto free_alt_parent;
> - }
> -
> if (nrates > 0) {
> - cpuclk->rate_count = nrates;
> cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates),
> GFP_KERNEL);
> if (!cpuclk->rate_table) {
> ret = -ENOMEM;
> - goto unregister_notifier;
> + goto free_alt_parent;
> }
> + cpuclk->rate_count = nrates;
> + }
> +
> + ret = clk_notifier_register(clk, &cpuclk->clk_nb);
> + if (ret) {
> + pr_err("%s: failed to register clock notifier for %s\n",
> + __func__, name);
> + goto free_rate_table;
> }
>
> cclk = clk_register(NULL, &cpuclk->hw);
> if (IS_ERR(cclk)) {
> - pr_err("%s: could not register cpuclk %s\n", __func__, name);
> + pr_err("%s: could not register cpuclk %s\n", __func__, name);
> ret = PTR_ERR(cclk);
> - goto free_rate_table;
> + goto unregister_notifier;
> }
>
> return cclk;
>
> -free_rate_table:
> - kfree(cpuclk->rate_table);
> unregister_notifier:
> clk_notifier_unregister(clk, &cpuclk->clk_nb);
> +free_rate_table:
> + kfree(cpuclk->rate_table);
> free_alt_parent:
> clk_disable_unprepare(cpuclk->alt_parent);
> free_cpuclk:
[Severity: High]
This problem wasn't introduced by this patch, but does
rockchip_clk_register_cpuclk_multi_pll() in the same file also register
cpuclk->clk_nb before allocating cpuclk->rate_table, and leak the notifier
[1] if kmemdup() fails?
drivers/clk/rockchip/clk-cpu.c:rockchip_clk_register_cpuclk_multi_pll() {
...
ret = clk_notifier_register(hw->clk, &cpuclk->clk_nb);
if (ret) {
pr_err("%s: failed to register clock notifier for %s\n",
__func__, name);
goto free_cpuclk;
}
if (nrates > 0) {
cpuclk->rate_count = nrates;
cpuclk->rate_table = kmemdup(rates,
sizeof(*rates) * nrates,
GFP_KERNEL);
if (!cpuclk->rate_table) {
ret = -ENOMEM;
goto free_cpuclk;
}
}
return hw->clk;
free_cpuclk:
kfree(cpuclk);
...
}
Jumping directly to free_cpuclk without calling clk_notifier_unregister()
leaves the freed cpuclk->clk_nb linked in clk_notifier_list, which can cause
a use-after-free or list corruption when the notifier chain is later
traversed or modified.
[1] https://sashiko.dev/#/bug/linux-1bafb3ff-a5b6-4219-9489-1455c756f137
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127192620.3443537-1-lee@kernel.org?part=5
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 01/10] clk: ti: fapll: Fix output clock array allocation and bounds check
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
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-27 19:36 UTC (permalink / raw)
To: Lee Jones, linux-clk
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] clk: ti: fapll: missing lower-bound check for index 0 in
ti_fapll_setup()
--
commit a8867d96413dfd436f2d0dca33e4c637a2d0da77
Author: Lee Jones <lee@kernel.org>
clk: ti: fapll: Fix output clock array allocation and bounds check
This commit allocates MAX_FAPLL_OUTPUTS + 1 pointer slots for
fd->outputs.clks and bounds-checks output_instance against
MAX_FAPLL_OUTPUTS.
> diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
> index 7d6a4dd4fc8ce..d5e95e6489cda 100644
> --- a/drivers/clk/ti/fapll.c
> +++ b/drivers/clk/ti/fapll.c
[ ... ]
> @@ -625,6 +624,12 @@ static void __init ti_fapll_setup(struct device_node *node)
> &output_instance))
> output_instance = i;
>
> + if (output_instance > MAX_FAPLL_OUTPUTS) {
> + pr_err("%pOFn invalid output_instance %u\n",
> + node, output_instance);
> + continue;
> + }
> +
> freq = fd->base + (output_instance * 8);
> div = freq + 4;
[Severity: Medium]
Should this check also reject output_instance == 0?
Child synthesizers are 1-based, while slot 0 of fd->outputs.clks is
populated with the parent pll_clk before this loop and register offsets 0
and 4 are the main PLL control and powerdown registers. If clock-indices
contains 0 or of_property_read_u32_index() fails on i == 0 and falls back
to output_instance = i, synth_clk aliases the main PLL registers and
overwrites fd->outputs.clks[0].
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127192620.3443537-1-lee@kernel.org?part=1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 02/10] clk: tegra: bpmp: Drop manual clock unregister on provider failure
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
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-27 19:36 UTC (permalink / raw)
To: Lee Jones, linux-clk
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] clk: tegra: error pointer dereference in
tegra_bpmp_clk_of_xlate() [1]
--
commit 44882aa0bdd34b806a054776ef80a0aa5e952e08
Author: Lee Jones <lee@kernel.org>
clk: tegra: bpmp: Drop manual clock unregister on provider failure
This commit removes tegra_bpmp_unregister_clocks() and its call on
of_clk_add_hw_provider() failure so devres handles clock cleanup without
dereferencing error pointers or double-unregistering clocks.
> diff --git a/drivers/clk/tegra/clk-bpmp.c b/drivers/clk/tegra/clk-bpmp.c
> index 3649324e2e1fd..e4b4f3eec7773 100644
> --- a/drivers/clk/tegra/clk-bpmp.c
> +++ b/drivers/clk/tegra/clk-bpmp.c
> @@ -648,14 +648,6 @@ static int tegra_bpmp_register_clocks(struct tegra_bpmp *bpmp,
> return 0;
> }
>
> -static void tegra_bpmp_unregister_clocks(struct tegra_bpmp *bpmp)
> -{
> - unsigned int i;
> -
> - for (i = 0; i < bpmp->num_clocks; i++)
> - clk_hw_unregister(&bpmp->clocks[i]->hw);
> -}
> -
> static struct clk_hw *tegra_bpmp_clk_of_xlate(struct of_phandle_args *clkspec,
> void *data)
> {
[Severity: High]
This problem wasn't introduced by this patch, but can
tegra_bpmp_clk_of_xlate() also dereference an error pointer in
bpmp->clocks[i] [1]?
drivers/clk/tegra/clk-bpmp.c:tegra_bpmp_clk_of_xlate() {
...
for (i = 0; i < bpmp->num_clocks; i++) {
struct tegra_bpmp_clk *clk = bpmp->clocks[i];
if (!clk)
continue;
if (clk->id == id)
return &clk->hw;
}
...
}
Because tegra_bpmp_register_clocks_one() stores ERR_PTR values in
bpmp->clocks[i] when a clock fails to register, checking only !clk before
reading clk->id will crash during device tree clock lookup. Should this
check IS_ERR_OR_NULL(clk)?
[1] https://sashiko.dev/#/bug/linux-3d54138a-c3d2-4466-952a-f7e44259adfe
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127192620.3443537-1-lee@kernel.org?part=2
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-11-27 19:36 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [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: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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox