mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: blaze <1466528493@qq.com>
To: vgupta@kernel.org
Cc: linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org,
	blaze <1466528493@qq.com>
Subject: [PATCH] arc: kernel: Fix clk reference leak in show_cpuinfo()
Date: Wed,  9 Sep 2026 12:42:59 +0800	[thread overview]
Message-ID: <tencent_0F7ECDD4429624B3213BD758BED2F788490A@qq.com> (raw)

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


             reply	other threads:[~2026-09-09  4:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09  4:42 blaze [this message]
2026-09-09  5:24 ` Vineet Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_0F7ECDD4429624B3213BD758BED2F788490A@qq.com \
    --to=1466528493@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=vgupta@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®