Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 01/10] clk: ti: fapll: Fix output clock array allocation and bounds check
       [not found] <20261127192620.3443537-1-lee@kernel.org>
@ 2026-11-27 19:25 ` Lee Jones
  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, 0 replies; 10+ 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] 10+ messages in thread

* [PATCH 02/10] clk: tegra: bpmp: Drop manual clock unregister on provider failure
       [not found] <20261127192620.3443537-1-lee@kernel.org>
  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:25 ` [PATCH 03/10] clk: starfive: jh7110-sys: Use devres for PLL0 clock and notifier Lee Jones
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 10+ 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] 10+ messages in thread

* [PATCH 03/10] clk: starfive: jh7110-sys: Use devres for PLL0 clock and notifier
       [not found] <20261127192620.3443537-1-lee@kernel.org>
  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; 10+ 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] 10+ messages in thread

* [PATCH 04/10] clk: starfive: jh7110: Duplicate top clock bulk arrays per device
       [not found] <20261127192620.3443537-1-lee@kernel.org>
                   ` (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; 10+ 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] 10+ messages in thread

* [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier
       [not found] <20261127192620.3443537-1-lee@kernel.org>
                   ` (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:25 ` [PATCH 06/10] clk: tegra: bpmp: Skip ERR_PTR entries in tegra_bpmp_clk_of_xlate() Lee Jones
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 10+ 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] 10+ messages in thread

* [PATCH 06/10] clk: tegra: bpmp: Skip ERR_PTR entries in tegra_bpmp_clk_of_xlate()
       [not found] <20261127192620.3443537-1-lee@kernel.org>
                   ` (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; 10+ 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] 10+ messages in thread

* [PATCH 07/10] clk: rp1: Propagate determine_rate() return value for PLL dividers
       [not found] <20261127192620.3443537-1-lee@kernel.org>
                   ` (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; 10+ 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] 10+ messages in thread

* [PATCH 08/10] clk: rp1: Reference secondary PLL divider clk_hw in parent tables
       [not found] <20261127192620.3443537-1-lee@kernel.org>
                   ` (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; 10+ 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] 10+ messages in thread

* [PATCH 09/10] clk: keystone: sci-clk: Check allocation failure before copying clock array
       [not found] <20261127192620.3443537-1-lee@kernel.org>
                   ` (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; 10+ 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] 10+ messages in thread

* [PATCH 10/10] clk: versatile: icst: Check kasprintf() and put parent node on error
       [not found] <20261127192620.3443537-1-lee@kernel.org>
                   ` (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; 10+ 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] 10+ messages in thread

end of thread, other threads:[~2026-11-27 19:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261127192620.3443537-1-lee@kernel.org>
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 ` [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: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