* [PATCH] i3c: master: Fix of_node reference leak in i3c_master_register()
@ 2026-09-16 16:03 Wentao Liang
[not found] ` <20260916161616.7B6B31F000FF@smtp.kernel.org>
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-16 16:03 UTC (permalink / raw)
To: Frank.Li
Cc: alexandre.belloni, arnd, bbrezillon, gregkh, linux-i3c,
linux-kernel, Wentao Liang, stable
The reference taken on the parent's device node with of_node_get() is
normally dropped by i3c_masterdev_release() once the master device is
unregistered. When i3c_master_rpm_get() fails, the function returns
before device_initialize(), so put_device() is never called and the
node reference is leaked.
Release the device node reference on the runtime PM failure path.
Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/i3c/master.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 5cd4e5da2233..23f490a00591 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -3033,8 +3033,10 @@ int i3c_master_register(struct i3c_master_controller *master,
INIT_LIST_HEAD(&master->boardinfo.i3c);
ret = i3c_master_rpm_get(master);
- if (ret)
+ if (ret) {
+ of_node_put(master->dev.of_node);
return ret;
+ }
device_initialize(&master->dev);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] i3c: master: Fix of_node reference leak in i3c_master_register()
[not found] ` <aqr19zvkGvMqRi2B@lizhi-Precision-Tower-5810>
@ 2026-11-08 9:28 ` Wentao Liang
0 siblings, 0 replies; 2+ messages in thread
From: Wentao Liang @ 2026-11-08 9:28 UTC (permalink / raw)
To: Frank Li; +Cc: Alexandre Belloni, Frank Li, linux-i3c, linux-kernel, vulab
Hi Frank,
Sorry for the very late reply.
Thank you for catching both problems. You are right, and I am sorry for
getting the API wrong in v1: the reference on the node is taken with
fwnode_handle_get(), so it has to be dropped with fwnode_handle_put().
of_node_put() only operates on Open Firmware nodes and is a no-op on ACPI
and software node systems, so the leak remained there.
On your second question: every other error branch in this function runs
after device_initialize(), and all of them end up at err_put_dev, where
put_device() calls i3c_masterdev_release() and that function drops the
fwnode with fwnode_handle_put(dev->fwnode). The i3c_master_rpm_get()
failure is the only path that returns before the device is initialized;
put_device() cannot be used there, so the reference has to be dropped
explicitly.
A v2 that calls fwnode_handle_put(dev_fwnode(&master->dev)), rebased on
current mainline, follows in a separate mail. I also dropped Cc: stable
there, since this only leaks on a registration failure path.
Thanks,
Wentao
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-08 9:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 16:03 [PATCH] i3c: master: Fix of_node reference leak in i3c_master_register() Wentao Liang
[not found] ` <20260916161616.7B6B31F000FF@smtp.kernel.org>
[not found] ` <aqr19zvkGvMqRi2B@lizhi-Precision-Tower-5810>
2026-11-08 9:28 ` Wentao Liang
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®