* [PATCH] i3c: master: Fix of_node reference leak in of_i3c_master_add_i2c_boardinfo()
@ 2026-09-16 16:06 Wentao Liang
2026-09-16 19:56 ` Frank Li
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-16 16:06 UTC (permalink / raw)
To: Frank.Li
Cc: alexandre.belloni, arnd, bbrezillon, gregkh, linux-i3c,
linux-kernel, Wentao Liang, stable
of_i2c_get_board_info() stores the device node in the board info's fwnode
without taking a reference, so the board info relies on the trailing
of_node_get() to keep the node alive. Nothing ever drops that reference:
the board info is devres-allocated and has no release callback.
Register the reference as a device-managed action of the I3C master so it
is released on registration failure and on controller teardown.
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 | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 23f490a00591..30b3822c530c 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -2407,6 +2407,11 @@ EXPORT_SYMBOL_GPL(i3c_master_add_i3c_dev_locked);
#define OF_I3C_REG1_IS_I2C_DEV BIT(31)
+static void of_i3c_master_put_node(void *data)
+{
+ of_node_put(data);
+}
+
static int
of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
struct device_node *node, u32 *reg)
@@ -2437,9 +2442,9 @@ of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
boardinfo->lvr = reg[2];
list_add_tail(&boardinfo->node, &master->boardinfo.i2c);
- of_node_get(node);
- return 0;
+ return devm_add_action_or_reset(dev, of_i3c_master_put_node,
+ of_node_get(node));
}
static int
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] i3c: master: Fix of_node reference leak in of_i3c_master_add_i2c_boardinfo()
2026-09-16 16:06 [PATCH] i3c: master: Fix of_node reference leak in of_i3c_master_add_i2c_boardinfo() Wentao Liang
@ 2026-09-16 19:56 ` Frank Li
0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2026-09-16 19:56 UTC (permalink / raw)
To: Wentao Liang
Cc: Frank.Li, alexandre.belloni, arnd, bbrezillon, gregkh, linux-i3c,
linux-kernel, stable
On Wed, Sep 16, 2026 at 04:06:54PM +0000, Wentao Liang wrote:
> of_i2c_get_board_info() stores the device node in the board info's fwnode
> without taking a reference, so the board info relies on the trailing
> of_node_get() to keep the node alive. Nothing ever drops that reference:
> the board info is devres-allocated and has no release callback.
>
> Register the reference as a device-managed action of the I3C master so it
> is released on registration failure and on controller teardown.
>
> 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 | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 23f490a00591..30b3822c530c 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -2407,6 +2407,11 @@ EXPORT_SYMBOL_GPL(i3c_master_add_i3c_dev_locked);
>
> #define OF_I3C_REG1_IS_I2C_DEV BIT(31)
>
> +static void of_i3c_master_put_node(void *data)
> +{
> + of_node_put(data);
> +}
> +
> static int
> of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
> struct device_node *node, u32 *reg)
which code base do you use, now use of_i2c_get_board_info()
Frank
> @@ -2437,9 +2442,9 @@ of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
> boardinfo->lvr = reg[2];
>
> list_add_tail(&boardinfo->node, &master->boardinfo.i2c);
> - of_node_get(node);
>
> - return 0;
> + return devm_add_action_or_reset(dev, of_i3c_master_put_node,
> + of_node_get(node));
> }
>
> static int
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-16 19:56 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:06 [PATCH] i3c: master: Fix of_node reference leak in of_i3c_master_add_i2c_boardinfo() Wentao Liang
2026-09-16 19:56 ` Frank Li
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®