DORMANTno replies

[PATCH 4/6] cpufreq: qoriq: Fix clock reference leak in set_affected_cpus()

From: Wentao Liang <hidden>
Date: 2026-09-15 04:34:04
Also in: lkml, stable
Subsystem: cpu frequency scaling framework, the rest · Maintainers: "Rafael J. Wysocki", Viresh Kumar, Linus Torvalds

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@vger.kernel.org
Signed-off-by: Wentao Liang <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help