mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] xtensa: time: Fix clk reference leak in calibrate_ccount()
@ 2026-09-10  5:07 blaze
  2026-09-10 10:49 ` Max Filippov
  0 siblings, 1 reply; 4+ messages in thread
From: blaze @ 2026-09-10  5:07 UTC (permalink / raw)
  To: jcmvbkbc, chris; +Cc: linux-kernel, 赵宇

From: 赵宇 <1466528493@qq.com>

In calibrate_ccount(), of_clk_get() acquires a reference to the CPU
clock, but clk_put() is never called to release it. The clock
reference is used only to read the frequency via clk_get_rate(),
then the function returns immediately, leaking the reference.

Fix this by calling clk_put(clk) before returning.

Signed-off-by: 赵宇 <1466528493@qq.com>
---
 arch/xtensa/kernel/time.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/xtensa/kernel/time.c b/arch/xtensa/kernel/time.c
index 09fda6a..bccc0e9 100644
--- a/arch/xtensa/kernel/time.c
+++ b/arch/xtensa/kernel/time.c
@@ -152,6 +152,7 @@ static void __init calibrate_ccount(void)
 		of_node_put(cpu);
 		if (!IS_ERR(clk)) {
 			ccount_freq = clk_get_rate(clk);
+			clk_put(clk);
 			return;
 		} else {
 			pr_warn("%s: CPU input clock not found\n",
-- 
2.53.0.windows.1


^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH] xtensa: time: Fix clk reference leak in calibrate_ccount()
@ 2026-09-09  4:43 blaze
  2026-09-09 15:39 ` Max Filippov
  0 siblings, 1 reply; 4+ messages in thread
From: blaze @ 2026-09-09  4:43 UTC (permalink / raw)
  To: chris, jcmvbkbc; +Cc: linux-kernel, blaze

In calibrate_ccount(), of_clk_get() acquires a reference to the CPU clock,
but clk_put() is never called to release it. The clock reference is used
only to read the frequency via clk_get_rate(), then the function returns
immediately, leaking the reference.

Fix this by calling clk_put(clk) before returning.

Fixes: a1f31a21e0c1 ("xtensa: add clocksource")
Signed-off-by: blaze <1466528493@qq.com>
---
 arch/xtensa/kernel/time.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/xtensa/kernel/time.c b/arch/xtensa/kernel/time.c
index 0000000..1111111 100644
--- a/arch/xtensa/kernel/time.c
+++ b/arch/xtensa/kernel/time.c
@@ -152,6 +152,7 @@ static void __init calibrate_ccount(void)
 		if (!IS_ERR(clk)) {
 			ccount_freq = clk_get_rate(clk);
+			clk_put(clk);
 			return;
 		} else {
 			pr_warn("%s: CPU input clock not found\n",
--
2.43.0


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

end of thread, other threads:[~2026-09-10 10:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-10  5:07 [PATCH] xtensa: time: Fix clk reference leak in calibrate_ccount() blaze
2026-09-10 10:49 ` Max Filippov
  -- strict thread matches above, loose matches on Subject: below --
2026-09-09  4:43 blaze
2026-09-09 15:39 ` Max Filippov

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®