public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
* [PATCH] clk: mvebu: ap-cpu: fix missing clk_put() in ap_cpu_clock_probe()
@ 2026-06-04  2:51 Wentao Liang
  2026-06-04  3:21 ` Andrew Lunn
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-06-04  2:51 UTC (permalink / raw)
  To: andrew, gregory.clement, sebastian.hesselbarth, mturquette, sboyd
  Cc: bmasney, linux-arm-kernel, linux-clk, linux-kernel, Wentao Liang,
	stable

The function ap_cpu_clock_probe() calls of_clk_get() to obtain a
reference to the parent clock for each CPU cluster, but it never
releases it with clk_put().  The returned clk is used only to read
the parent's name via __clk_get_name(), and the reference is leaked
on every successful cluster initialization as well as on the error
path when devm_clk_hw_register() fails.

Add the missing clk_put() after the name has been extracted and
before returning on error to fix the leak.

Fixes: af9617b419f7 ("clk: mvebu: ap-cpu-clk: Fix a memory leak in error handling paths")
Cc: stable@vger•kernel.org
Signed-off-by: Wentao Liang <vulab@iscas•ac.cn>
---
 drivers/clk/mvebu/ap-cpu-clk.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/mvebu/ap-cpu-clk.c b/drivers/clk/mvebu/ap-cpu-clk.c
index 1e44ace7d951..a8175908e353 100644
--- a/drivers/clk/mvebu/ap-cpu-clk.c
+++ b/drivers/clk/mvebu/ap-cpu-clk.c
@@ -328,9 +328,11 @@ static int ap_cpu_clock_probe(struct platform_device *pdev)
 		ret = devm_clk_hw_register(dev, &ap_cpu_clk[cluster_index].hw);
 		if (ret) {
 			of_node_put(dn);
+			clk_put(parent);
 			return ret;
 		}
 		ap_cpu_data->hws[cluster_index] = &ap_cpu_clk[cluster_index].hw;
+		clk_put(parent);
 	}
 
 	ap_cpu_data->num = cluster_index + 1;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] clk: mvebu: ap-cpu: fix missing clk_put() in ap_cpu_clock_probe()
  2026-06-04  2:51 [PATCH] clk: mvebu: ap-cpu: fix missing clk_put() in ap_cpu_clock_probe() Wentao Liang
@ 2026-06-04  3:21 ` Andrew Lunn
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2026-06-04  3:21 UTC (permalink / raw)
  To: Wentao Liang
  Cc: gregory.clement, sebastian.hesselbarth, mturquette, sboyd,
	bmasney, linux-arm-kernel, linux-clk, linux-kernel, stable

On Thu, Jun 04, 2026 at 02:51:15AM +0000, Wentao Liang wrote:
> The function ap_cpu_clock_probe() calls of_clk_get() to obtain a
> reference to the parent clock for each CPU cluster, but it never
> releases it with clk_put().  The returned clk is used only to read
> the parent's name via __clk_get_name(), and the reference is leaked
> on every successful cluster initialization as well as on the error
> path when devm_clk_hw_register() fails.

Is there potentially a different interpretation?

If the parent clock was to disappear, the clocks to the CPU would
disappear, resulting in a dead system. By keeping a reference on the
parent, it cannot disappear?

Also, do we care that much about the error case? If we fail to setup
the CPU clock, how much longer is the CPU going to run before it dies
a horrible death?

> Add the missing clk_put() after the name has been extracted and
> before returning on error to fix the leak.
> 
> Fixes: af9617b419f7 ("clk: mvebu: ap-cpu-clk: Fix a memory leak in error handling paths")
> Cc: stable@vger•kernel.org

Does this actually bother people? It needs to in order to be sent to
stable:

https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html

     Andrew


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-04  3:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04  2:51 [PATCH] clk: mvebu: ap-cpu: fix missing clk_put() in ap_cpu_clock_probe() Wentao Liang
2026-06-04  3:21 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox