From: Ruoyu Wang <ruoyuw560@gmail.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>,
Frank Li <Frank.Li@nxp.com>,
Boris Brezillon <bbrezillon@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Arnd Bergmann <arnd@arndb.de>
Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org,
Ruoyu Wang <ruoyuw560@gmail.com>
Subject: [PATCH] i3c: master: Release I2C boardinfo node reference
Date: Fri, 14 Aug 2026 21:40:27 +0800 [thread overview]
Message-ID: <20260814134027.1386818-1-ruoyuw560@gmail.com> (raw)
of_i3c_master_add_i2c_boardinfo() takes a reference to each Device Tree
child node so the fwnode stored in the persistent board info remains
valid. i2c_new_client_device() later takes its own reference for the
client, and client teardown only releases that reference. The original
board-info reference is therefore leaked for every DT-described I2C
device. Registration failures after bus population leak it as well.
Register the board-info node reference as a managed resource of the I3C
master. This retains it for the full board-info lifetime and releases it
on both registration failure and normal master teardown.
This issue was found by a static analysis checker and confirmed by
manual source review.
Fixes: 3a379bbcea0af ("i3c: Add core I3C infrastructure")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
drivers/i3c/master.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index f1be38a640ca1..8063e2642cbda 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -2619,6 +2619,11 @@ EXPORT_SYMBOL_GPL(i3c_master_do_daa);
#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)
@@ -2648,8 +2653,12 @@ of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
/* LVR is encoded in reg[2]. */
boardinfo->lvr = reg[2];
+ ret = devm_add_action_or_reset(dev, of_i3c_master_put_node,
+ of_node_get(node));
+ if (ret)
+ return ret;
+
list_add_tail(&boardinfo->node, &master->boardinfo.i2c);
- of_node_get(node);
return 0;
}
--
2.51.0
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next reply other threads:[~2026-08-14 13:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 13:40 Ruoyu Wang [this message]
2026-08-14 13:58 ` [PATCH] i3c: master: Release I2C boardinfo node reference sashiko-bot
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=20260814134027.1386818-1-ruoyuw560@gmail.com \
--to=ruoyuw560@gmail.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 \
/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