From: Wentao Liang <vulab@iscas.ac.cn>
To: dakr@kernel.org
Cc: driver-core@lists.linux.dev, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org, rafael@kernel.org,
rob.herring@calxeda.com, sudeep.holla@kernel.org,
lkml@vger.kernel.org, Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH 5/6] driver core: cpu: Fix OF node reference leak in register_cpu() error path
Date: Tue, 15 Sep 2026 04:35:23 +0000 [thread overview]
Message-ID: <20260915043523.1725991-1-vulab@iscas.ac.cn> (raw)
register_cpu() assigns the device node returned by of_get_cpu_node(),
which comes with a reference, to cpu->dev.of_node. If device_register()
fails, the error path calls put_device() and returns, but nothing ever
drops the OF node reference: cpu_device_release() is empty and the
driver core does not put dev->of_node on the failure path, so each
failed registration leaks a reference on the device node.
Release the OF node with of_node_put() on the error path. It is safe
to access cpu->dev.of_node after put_device(), since the statically
allocated struct cpu is never freed by cpu_device_release().
Fixes: f86e4718f24b ("driver/core: cpu: initialize of_node in cpu's device struture")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/base/cpu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 875abdc9942e..bc96725c8d4c 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -431,6 +431,7 @@ int register_cpu(struct cpu *cpu, int num)
error = device_register(&cpu->dev);
if (error) {
put_device(&cpu->dev);
+ of_node_put(cpu->dev.of_node);
return error;
}
--
2.34.1
next reply other threads:[~2026-09-15 4:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 4:35 Wentao Liang [this message]
2026-09-23 8:40 ` Sudeep Holla
2026-11-05 9:22 ` [PATCH v2] " Wentao Liang
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=20260915043523.1725991-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rob.herring@calxeda.com \
--cc=stable@vger.kernel.org \
--cc=sudeep.holla@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®