* [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
* Re: [PATCH] xtensa: time: Fix clk reference leak in calibrate_ccount()
2026-09-10 5:07 [PATCH] xtensa: time: Fix clk reference leak in calibrate_ccount() blaze
@ 2026-09-10 10:49 ` Max Filippov
0 siblings, 0 replies; 4+ messages in thread
From: Max Filippov @ 2026-09-10 10:49 UTC (permalink / raw)
To: blaze; +Cc: chris, linux-kernel
On Wed, Sep 9, 2026 at 10:07 PM blaze <1466528493@qq.com> wrote:
>
> 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(+)
Thank you for taking time to explain and resubmit.
Applied to my xtensa tree.
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [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, 0 replies; 4+ messages in thread
From: Max Filippov @ 2026-09-09 15:39 UTC (permalink / raw)
To: blaze; +Cc: chris, linux-kernel
Hi,
On Tue, Sep 8, 2026 at 9:43 PM blaze <1466528493@qq.com> wrote:
> 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>
the handle "blaze <1466528493@qq.com>" doesn't look like a known identity,
as Documentation/process/submitting-patches.rst requires, and it's one of the
first appearances of this name in the LKML. Could you please re-submit using
something less anonymous?
> ---
> 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
>
The change itself looks good, thanks.
-- Max
^ 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®