mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] arc: kernel: Fix clk reference leak in show_cpuinfo()
@ 2026-09-09  4:42 blaze
  2026-09-09  5:24 ` Vineet Gupta
  0 siblings, 1 reply; 2+ messages in thread
From: blaze @ 2026-09-09  4:42 UTC (permalink / raw)
  To: vgupta; +Cc: linux-snps-arc, linux-kernel, blaze

In show_cpuinfo(), clk_get() acquires a reference to the CPU clock, but
clk_put() is never called to release it. Since show_cpuinfo() is the
seq_file show callback for /proc/cpuinfo, this causes a clock reference
count leak every time /proc/cpuinfo is read.

The frequency is extracted via clk_get_rate() into a local variable, so
the clock reference can be safely released immediately after.

Fix this by calling clk_put(cpu_clk) right after clk_get_rate().

Fixes: 98f2892607c5 ("ARC: [cpuinfo] Add clk info in /proc/cpuinfo")
Signed-off-by: blaze <1466528493@qq.com>
---
 arch/arc/kernel/setup.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index 0000000..1111111 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -593,6 +593,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 				   cpu_id);
 	} else {
 		freq = clk_get_rate(cpu_clk);
+		clk_put(cpu_clk);
 	}
 	if (freq)
 		seq_printf(m, "CPU speed\t: %lu.%02lu Mhz\n",
--
2.43.0


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

* Re: [PATCH] arc: kernel: Fix clk reference leak in show_cpuinfo()
  2026-09-09  4:42 [PATCH] arc: kernel: Fix clk reference leak in show_cpuinfo() blaze
@ 2026-09-09  5:24 ` Vineet Gupta
  0 siblings, 0 replies; 2+ messages in thread
From: Vineet Gupta @ 2026-09-09  5:24 UTC (permalink / raw)
  To: blaze, vgupta; +Cc: linux-snps-arc, linux-kernel

On 9/9/26 10:12 AM, blaze wrote:
> In show_cpuinfo(), clk_get() acquires a reference to the CPU clock, but
> clk_put() is never called to release it. Since show_cpuinfo() is the
> seq_file show callback for /proc/cpuinfo, this causes a clock reference
> count leak every time /proc/cpuinfo is read.
>
> The frequency is extracted via clk_get_rate() into a local variable, so
> the clock reference can be safely released immediately after.
>
> Fix this by calling clk_put(cpu_clk) right after clk_get_rate().

Thx for the fix and right on time as I was queuing up changes.

Acked-by: Vineet Gupta <vgupta@kernel.org>

Thx,
-Vineet

> Fixes: 98f2892607c5 ("ARC: [cpuinfo] Add clk info in /proc/cpuinfo")
> Signed-off-by: blaze<1466528493@qq.com>
> ---
>   arch/arc/kernel/setup.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
> index 0000000..1111111 100644
> --- a/arch/arc/kernel/setup.c
> +++ b/arch/arc/kernel/setup.c
> @@ -593,6 +593,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
>   				   cpu_id);
>   	} else {
>   		freq = clk_get_rate(cpu_clk);
> +		clk_put(cpu_clk);
>   	}
>   	if (freq)
>   		seq_printf(m, "CPU speed\t: %lu.%02lu Mhz\n",
> --
> 2.43.0
>


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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09  4:42 [PATCH] arc: kernel: Fix clk reference leak in show_cpuinfo() blaze
2026-09-09  5:24 ` Vineet Gupta

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®