Re: [PATCH] cpufreq: spear: Fix clock reference leak in spear_cpufreq_target()

From: Zhongqiu Han

Date: Wed Nov 18 2026 - 01:55:11 EST


On 11/18/2026 1:32 PM, Haoxiang Li wrote:
spear1340_cpu_get_possible_parent() acquires a clock reference with
clk_get() for each frequency transition. However,spear_cpufreq_target()

Nit: missing space after the comma.

never releases this reference, leaking a clock consumer object and its
reference on both success and error paths. Add a common cleanup path to
release the source clock reference.

Fixes: 420993221175 ("cpufreq: SPEAr: Add CPUFreq driver")
Signed-off-by: Haoxiang Li <haoxiang_li2024@xxxxxxx>


Reviewed-by: Zhongqiu Han <zhongqiu.han@xxxxxxxxxxxxxxxx> (with a nit
inline)

---
drivers/cpufreq/spear-cpufreq.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index ffe5eda82f0b..7f3fd6eca854 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -136,7 +136,8 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,
newfreq = clk_round_rate(srcclk, newfreq * mult);
if (newfreq <= 0) {
pr_err("clk_round_rate failed for cpu src clock\n");
- return newfreq;
+ ret = newfreq;
+ goto err_put;
}
if (mult == 2)
@@ -147,6 +148,9 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,
if (ret)
pr_err("CPU Freq: cpu clk_set_rate failed: %d\n", ret);
+err_put:

Nit: this label is also reached on the success path, so something like
"out_put_clk" would be a more accurate name than "err_put".

+ if (mult == 2)
+ clk_put(srcclk);
return ret;
}


--
Thx and BRs,
Zhongqiu Han