From: Frank Li <Frank.li@oss.nxp.com>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: Frank.Li@nxp.com, alexandre.belloni@bootlin.com, arnd@arndb.de,
bbrezillon@kernel.org, gregkh@linuxfoundation.org,
linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] i3c: master: Fix of_node reference leak in of_i3c_master_add_i2c_boardinfo()
Date: Wed, 16 Sep 2026 15:56:44 -0400 [thread overview]
Message-ID: <aqr0fHT3EcOlExAj@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260916160654.2081795-1-vulab@iscas.ac.cn>
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
>
prev parent reply other threads:[~2026-09-16 19:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 16:06 Wentao Liang
2026-09-16 19:56 ` Frank Li [this message]
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=aqr0fHT3EcOlExAj@lizhi-Precision-Tower-5810 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=arnd@arndb.de \
--cc=bbrezillon@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
/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®