[PATCH] clocksource/drivers/timer-pxa: Fix clock reference leak

DORMANTno replies

From: Wentao Liang <hidden>
Date: 2026-09-15 05:44:16
Also in: lkml
Subsystem: clocksource, clockevent drivers, the rest · Maintainers: Daniel Lezcano, Thomas Gleixner, Linus Torvalds

pxa_timer_dt_init() obtains the timer clock with of_clk_get() but never
releases the consumer reference: the clk_prepare_enable() failure path,
the irq_of_parse_and_map() failure path and the success path all return
without clk_put(), leaking the reference on each init attempt.

Call clk_put() on all three paths. The clock is left prepared and
enabled, so the timer behaviour is unchanged.

Fixes: ab5354c48d58 ("clocksource: pxa: Add device-tree support for PXA timer")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <redacted>
---
 drivers/clocksource/timer-pxa.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/clocksource/timer-pxa.c b/drivers/clocksource/timer-pxa.c
index 7ad0e5adb2ff..8bb473b75b48 100644
--- a/drivers/clocksource/timer-pxa.c
+++ b/drivers/clocksource/timer-pxa.c
@@ -195,6 +195,7 @@ static int __init pxa_timer_dt_init(struct device_node *np)
 	ret = clk_prepare_enable(clk);
 	if (ret) {
 		pr_crit("Failed to prepare clock\n");
+		clk_put(clk);
 		return ret;
 	}
 
@@ -202,10 +203,14 @@ static int __init pxa_timer_dt_init(struct device_node *np)
 	irq = irq_of_parse_and_map(np, 0);
 	if (irq <= 0) {
 		pr_crit("%pOFn: unable to parse OS-timer0 irq\n", np);
+		clk_put(clk);
 		return -EINVAL;
 	}
 
-	return pxa_timer_common_init(irq, clk_get_rate(clk));
+	ret = pxa_timer_common_init(irq, clk_get_rate(clk));
+	clk_put(clk);
+
+	return ret;
 }
 TIMER_OF_DECLARE(pxa_timer, "marvell,pxa-timer", pxa_timer_dt_init);
 
-- 
2.34.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help