[PATCH] clocksource/drivers/asm9260: Fix clk reference leak in error paths
From: Wentao Liang
Date: Tue Sep 15 2026 - 00:50:45 EST
asm9260_timer_init() obtains a clock reference with of_clk_get() but
never calls clk_put(). If clk_prepare_enable() fails, the reference is
leaked directly, and if request_irq() fails the error path only calls
clk_disable_unprepare(), which releases the prepare/enable state but not
the reference obtained from of_clk_get().
Add the missing clk_put() calls on both error paths so the clock
reference is no longer leaked. The success path keeps the clock enabled
for the lifetime of the timer and is left untouched.
Fixes: 8d8bd7be8bf0 ("ARM: clocksource: Add asm9260_timer driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/clocksource/asm9260_timer.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/clocksource/asm9260_timer.c b/drivers/clocksource/asm9260_timer.c
index 8f97ab0b01ec..f0ba19c9e0cf 100644
--- a/drivers/clocksource/asm9260_timer.c
+++ b/drivers/clocksource/asm9260_timer.c
@@ -202,6 +202,7 @@ static int __init asm9260_timer_init(struct device_node *np)
ret = clk_prepare_enable(clk);
if (ret) {
pr_err("Failed to enable clk!\n");
+ clk_put(clk);
return ret;
}
@@ -211,6 +212,7 @@ static int __init asm9260_timer_init(struct device_node *np)
if (ret) {
pr_err("Failed to setup irq!\n");
clk_disable_unprepare(clk);
+ clk_put(clk);
return ret;
}
--
2.34.1