[PATCH] clocksource/drivers/integrator-ap: Fix clk reference leak in error paths

From: Wentao Liang

Date: Tue Sep 15 2026 - 00:59:06 EST


integrator_ap_timer_init_of() obtains the timer clock with of_clk_get()
and enables it, but the of_property_read_string() failure paths for the
"arm,timer-primary" and "arm,timer-secondary" aliases return without
releasing the clock, leaking both the enable/prepare state and the
reference itself.

Disable and put the clock before returning on both failure paths. The
paths that hand the timer over to the clocksource or clockevent code
keep the clock enabled for the lifetime of the timer and are left
untouched.

Fixes: 76804d052316 ("clocksource/drivers/integrator-ap: Convert init function to return error")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/clocksource/timer-integrator-ap.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/clocksource/timer-integrator-ap.c b/drivers/clocksource/timer-integrator-ap.c
index a4c700b11dc0..a4cd0d79dd29 100644
--- a/drivers/clocksource/timer-integrator-ap.c
+++ b/drivers/clocksource/timer-integrator-ap.c
@@ -182,6 +182,8 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
"arm,timer-primary", &path);
if (err) {
pr_warn("Failed to read property\n");
+ clk_disable_unprepare(clk);
+ clk_put(clk);
return err;
}

@@ -202,6 +204,8 @@ static int __init integrator_ap_timer_init_of(struct device_node *node)
"arm,timer-secondary", &path);
if (err) {
pr_warn("Failed to read property\n");
+ clk_disable_unprepare(clk);
+ clk_put(clk);
return err;
}

--
2.34.1