[PATCH 4/6] cpufreq: qoriq: Fix clock reference leak in set_affected_cpus()
From: Wentao Liang
Date: Tue Sep 15 2026 - 00:35:36 EST
cpu_to_clk() returns a consumer clock obtained with of_clk_get(), but
set_affected_cpus() never releases it. The reference is only used for
a clk_is_match() comparison, and each iteration of the
for_each_present_cpu() loop overwrites the 'clk' pointer with a newly
obtained reference, leaking all but the last one (which is leaked too,
once the loop ends).
Put the clock back with clk_put() once the comparison is done.
clk_put() also tolerates the NULL clock that cpu_to_clk() returns for
a CPU without a clock node.
Fixes: b1e9a64972bf ("cpufreq: qoriq: Don't look at clock implementation details")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/cpufreq/qoriq-cpufreq.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c
index 13d3333e68d8..7a004782ff62 100644
--- a/drivers/cpufreq/qoriq-cpufreq.c
+++ b/drivers/cpufreq/qoriq-cpufreq.c
@@ -98,6 +98,8 @@ static void set_affected_cpus(struct cpufreq_policy *policy)
if (clk_is_match(policy->clk, clk))
cpumask_set_cpu(i, dstp);
+
+ clk_put(clk);
}
}
--
2.34.1