arch/arc/kernel/setup.c | 1 + 1 file changed, 1 insertion(+)
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
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
>
© 2016 - 2026 Red Hat, Inc.