mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpufreq: spear: Fix clock reference leak in spear_cpufreq_target()
@ 2026-11-18  5:32 Haoxiang Li
  2026-11-18  6:54 ` Zhongqiu Han
  0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-11-18  5:32 UTC (permalink / raw)
  To: rafael, viresh.kumar, deepak.sikri; +Cc: linux-pm, linux-kernel, Haoxiang Li

spear1340_cpu_get_possible_parent() acquires a clock reference with
clk_get() for each frequency transition. However,spear_cpufreq_target()
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@163.com>
---
 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:
+	if (mult == 2)
+		clk_put(srcclk);
 	return ret;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-18  6:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18  5:32 [PATCH] cpufreq: spear: Fix clock reference leak in spear_cpufreq_target() Haoxiang Li
2026-11-18  6:54 ` Zhongqiu Han

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®