From: sashiko-bot@kernel.org
To: "Akhil R" <akhilrajeev@nvidia.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v2 03/13] i3c: master: Use unified device property interface
Date: Thu, 09 Apr 2026 11:53:04 +0000 [thread overview]
Message-ID: <20260409115305.0918CC4CEF7@smtp.kernel.org> (raw)
In-Reply-To: <20260409105747.48158-4-akhilrajeev@nvidia.com>
Sashiko AI review found 3 potential issue(s):
- [High] I3C master registration unconditionally fails on ACPI systems if child nodes are present, breaking existing ACPI support.
- [High] Failure during device registration leaves a dangling pointer in `desc->dev`, leading to a Use-After-Free and Double Free during bus teardown.
- [High] Erroneous consumption of the `boardinfo` fwnode reference during device release causes a reference underflow and potential Use-After-Free.
--
commit 97e72c86c4ba51a8b484696ee0603781ab0f1651
Author: Akhil R <akhilrajeev@nvidia.com>
Subject: i3c: master: Use unified device property interface
This commit replaces OF-specific functions with unified device property
functions to prepare for supporting both ACPI and device tree.
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
[ ... ]
> @@ -995,7 +997,7 @@ static void i3c_device_release(struct device *dev)
>
> WARN_ON(i3cdev->desc);
>
> - of_node_put(i3cdev->dev.of_node);
> + fwnode_handle_put(dev->fwnode);
> kfree(i3cdev);
> }
[ ... ]
> @@ -1783,7 +1785,7 @@ i3c_master_register_new_i3c_devs(struct i3c_master_controller *master)
> desc->info.pid);
>
> if (desc->boardinfo)
> - desc->dev->dev.of_node = desc->boardinfo->of_node;
> + device_set_node(&desc->dev->dev, desc->boardinfo->fwnode);
>
> ret = device_register(&desc->dev->dev);
> if (ret) {
Will this cause a reference underflow on the boardinfo fwnode?
When the device is registered, device_set_node() assigns the fwnode without
taking an extra reference. If the device is released (for instance, in the
device_register error path shown above), i3c_device_release() calls
fwnode_handle_put(). This consumes the reference that is actually owned by
boardinfo.
If the device is later rediscovered via hot-join, it could match the same
boardinfo and use the freed fwnode, resulting in a use-after-free.
Additionally, does this error path leave a dangling pointer in desc->dev?
While this is a pre-existing issue, if device_register() fails, it calls
put_device() which triggers i3c_device_release() and frees desc->dev via
kfree(). However, desc->dev is not set to NULL. Later during teardown,
i3c_master_unregister_i3c_devs() might skip the !i3cdev->dev check, write
to the freed memory, and call put_device() again, causing a double-free.
[ ... ]
> @@ -2402,8 +2404,8 @@ EXPORT_SYMBOL_GPL(i3c_master_add_i3c_dev_locked);
> #define OF_I3C_REG1_IS_I2C_DEV BIT(31)
>
> static int
> -of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
> - struct device_node *node, u32 *reg)
> +i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
> + struct fwnode_handle *fwnode, u32 *reg)
> {
> struct i2c_dev_boardinfo *boardinfo;
> struct device *dev = &master->dev;
> @@ -2413,9 +2415,13 @@ of_i3c_master_add_i2c_boardinfo(struct i3c_master_controller *master,
> if (!boardinfo)
> return -ENOMEM;
>
> - ret = of_i2c_get_board_info(dev, node, &boardinfo->base);
> - if (ret)
> - return ret;
> + if (is_of_node(fwnode)) {
> + ret = of_i2c_get_board_info(dev, to_of_node(fwnode), &boardinfo->base);
> + if (ret)
> + return ret;
> + } else {
> + return -EINVAL;
> + }
[ ... ]
> -static int of_populate_i3c_bus(struct i3c_master_controller *master)
> +static int fwnode_populate_i3c_bus(struct i3c_master_controller *master)
> {
> struct device *dev = &master->dev;
> - struct device_node *i3cbus_np = dev->of_node;
> + struct fwnode_handle *fwnode = dev_fwnode(dev);
> int ret;
> u32 val;
>
> - if (!i3cbus_np)
> + if (!fwnode)
> return 0;
>
> - for_each_available_child_of_node_scoped(i3cbus_np, node) {
> - ret = of_i3c_master_add_dev(master, node);
> + fwnode_for_each_available_child_node_scoped(fwnode, child) {
> + ret = i3c_master_add_dev(master, child);
> if (ret)
> return ret;
> }
Does this change break I3C master registration on ACPI systems?
Previously, of_populate_i3c_bus() would return 0 on ACPI platforms because
dev->of_node was NULL. Now, fwnode_populate_i3c_bus() unconditionally
iterates over all ACPI child nodes.
Since i3c_master_add_dev() expects a device tree style reg property (which
ACPI nodes typically lack in favor of _CRS or _ADR), reading it may fail.
Additionally, if a child is identified as an I2C device, the new
i3c_master_add_i2c_boardinfo() explicitly returns -EINVAL for non-OF nodes.
These errors will propagate up and completely abort i3c_master_register().
Even if ACPI support is fixed in a subsequent commit, could this intermediate
patch break bisectability by causing the controller to fail probing?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260409105747.48158-1-akhilrajeev@nvidia.com?part=3
next prev parent reply other threads:[~2026-04-09 11:53 UTC|newest]
Thread overview: 113+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 10:57 [PATCH v2 00/13] Support ACPI and SETAASA device discovery Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-09 10:57 ` [PATCH v2 01/13] dt-bindings: i3c: Add mipi-i3c-static-method to support SETAASA Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-09 11:14 ` sashiko-bot
2026-04-10 2:00 ` Frank Li
2026-04-10 2:00 ` Frank Li
2026-04-10 4:30 ` Akhil R
2026-04-10 4:30 ` Akhil R
2026-04-16 11:59 ` Rob Herring
2026-04-16 11:59 ` Rob Herring
2026-04-09 10:57 ` [PATCH v2 02/13] ACPICA: Read LVR from the I2C resource descriptor Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-09 11:07 ` Rafael J. Wysocki
2026-04-09 11:07 ` Rafael J. Wysocki
2026-04-09 11:20 ` sashiko-bot
2026-04-10 2:04 ` Frank Li
2026-04-10 2:04 ` Frank Li
2026-04-10 4:45 ` Akhil R
2026-04-10 4:45 ` Akhil R
2026-04-10 10:59 ` Rafael J. Wysocki
2026-04-10 10:59 ` Rafael J. Wysocki
2026-04-11 5:41 ` Akhil R
2026-04-11 5:41 ` Akhil R
2026-04-10 10:57 ` Rafael J. Wysocki
2026-04-10 10:57 ` Rafael J. Wysocki
2026-04-09 10:57 ` [PATCH v2 03/13] i3c: master: Use unified device property interface Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-09 11:53 ` sashiko-bot [this message]
2026-04-09 10:57 ` [PATCH v2 04/13] i3c: master: Support ACPI enumeration of child devices Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-09 11:43 ` sashiko-bot
2026-04-10 2:17 ` Frank Li
2026-04-10 2:17 ` Frank Li
2026-04-10 5:31 ` Akhil R
2026-04-10 5:31 ` Akhil R
2026-04-12 20:18 ` Alexandre Belloni
2026-04-12 20:18 ` Alexandre Belloni
2026-04-09 10:57 ` [PATCH v2 05/13] i3c: master: Add support for devices using SETAASA Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-09 11:45 ` sashiko-bot
2026-04-10 2:25 ` Frank Li
2026-04-10 2:25 ` Frank Li
2026-04-09 10:57 ` [PATCH v2 06/13] i3c: master: Add support for devices without PID Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-09 12:08 ` sashiko-bot
2026-04-10 2:37 ` Frank Li
2026-04-10 2:37 ` Frank Li
2026-04-09 10:57 ` [PATCH v2 07/13] i3c: master: match I3C device through DT and ACPI Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-10 2:40 ` Frank Li
2026-04-10 2:40 ` Frank Li
2026-04-09 10:57 ` [PATCH v2 08/13] i3c: dw-i3c-master: Add SETAASA as supported CCC Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-10 2:41 ` Frank Li
2026-04-10 2:41 ` Frank Li
2026-04-09 10:57 ` [PATCH v2 09/13] i3c: dw-i3c-master: Add a quirk to skip clock and reset Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-09 11:51 ` sashiko-bot
2026-04-10 2:45 ` Frank Li
2026-04-10 2:45 ` Frank Li
2026-04-10 6:07 ` Akhil R
2026-04-10 6:07 ` Akhil R
2026-04-13 8:45 ` Alexandre Belloni
2026-04-13 8:45 ` Alexandre Belloni
2026-04-09 10:57 ` [PATCH v2 10/13] i3c: dw-i3c-master: Add ACPI ID for Tegra410 Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-10 2:47 ` Frank Li
2026-04-10 2:47 ` Frank Li
2026-04-09 10:57 ` [PATCH v2 11/13] hwmon: spd5118: Remove 16-bit addressing Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-09 14:11 ` Guenter Roeck
2026-04-09 14:11 ` Guenter Roeck
2026-04-09 10:57 ` [PATCH v2 12/13] hwmon: spd5118: Add I3C support Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-09 12:36 ` sashiko-bot
2026-04-09 14:15 ` Guenter Roeck
2026-04-09 14:19 ` Guenter Roeck
2026-04-09 14:19 ` Guenter Roeck
2026-04-12 20:16 ` Alexandre Belloni
2026-04-12 20:16 ` Alexandre Belloni
2026-04-12 21:26 ` Guenter Roeck
2026-04-12 21:26 ` Guenter Roeck
2026-04-09 10:57 ` [PATCH v2 13/13] arm64: defconfig: Enable I3C and SPD5118 hwmon Akhil R
2026-04-09 10:57 ` Akhil R
2026-04-10 6:39 ` Krzysztof Kozlowski
2026-04-10 6:39 ` Krzysztof Kozlowski
2026-04-10 6:57 ` Guenter Roeck
2026-04-10 6:57 ` Guenter Roeck
2026-04-10 7:18 ` Krzysztof Kozlowski
2026-04-10 7:18 ` Krzysztof Kozlowski
2026-04-10 8:37 ` Akhil R
2026-04-10 8:37 ` Akhil R
2026-04-10 9:57 ` Krzysztof Kozlowski
2026-04-10 9:57 ` Krzysztof Kozlowski
2026-04-11 5:34 ` Akhil R
2026-04-11 5:34 ` Akhil R
2026-04-11 7:20 ` Guenter Roeck
2026-04-11 7:20 ` Guenter Roeck
2026-04-12 13:32 ` Krzysztof Kozlowski
2026-04-12 13:32 ` Krzysztof Kozlowski
2026-04-12 13:33 ` Krzysztof Kozlowski
2026-04-12 13:33 ` Krzysztof Kozlowski
2026-04-13 6:57 ` Akhil R
2026-04-13 6:57 ` Akhil R
2026-04-13 7:12 ` Krzysztof Kozlowski
2026-04-13 7:12 ` Krzysztof Kozlowski
2026-04-13 10:46 ` Akhil R
2026-04-13 10:46 ` Akhil R
2026-04-12 13:21 ` Krzysztof Kozlowski
2026-04-12 13:21 ` Krzysztof Kozlowski
2026-04-10 7:04 ` Akhil R
2026-04-10 7:04 ` Akhil R
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=20260409115305.0918CC4CEF7@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akhilrajeev@nvidia.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.