All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Akhil R" <akhilrajeev@nvidia.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v3 03/13] i3c: master: Use unified device property interface
Date: Thu, 23 Apr 2026 20:08:34 +0000	[thread overview]
Message-ID: <20260423200835.5A10FC2BCAF@smtp.kernel.org> (raw)
In-Reply-To: <20260423085718.70762-4-akhilrajeev@nvidia.com>

Sashiko AI review found 2 potential issue(s):
- [Critical] Dangling fwnode pointer in boardinfo leading to Use-After-Free on device hot-plug.
- [High] Master registration fails on ACPI systems due to mandatory OF-specific property checks.
--

commit bc7c2a6c59d2e2a9a674fb4e8a851cbc8852b1e2
Author: Akhil R <akhilrajeev@nvidia.com>

i3c: master: Use unified device property interface

This commit replaces OF-specific functions with unified device property
functions to serve as a prerequisite for supporting both ACPI and device
tree.

> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 5cd4e5da22333..d0677061faab4 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
[ ... ]
> @@ -993,7 +995,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);
>  }
>  
[ ... ]
> @@ -1789,7 +1791,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);

Can this result in a use-after-free if a device is hot-unplugged and later
re-registered?

Since device_set_node() does not increment the fwnode reference count, the
device shares the reference owned by boardinfo.

During device unregistration, i3c_device_release() unconditionally calls
fwnode_handle_put(dev->fwnode), dropping that single reference.

If the device is subsequently hot-plugged, will the cached boardinfo reuse
the now-freed fwnode pointer? Would it be safer to acquire a new reference
when setting the device node, like fwnode_handle_get(desc->boardinfo->fwnode)?

[ ... ]
> @@ -2499,7 +2505,7 @@ static int of_i3c_master_add_dev(struct i3c_master_controller *master,
>  	if (!master)
>  		return -EINVAL;
>  
> -	ret = of_property_read_u32_array(node, "reg", reg, ARRAY_SIZE(reg));
> +	ret = fwnode_property_read_u32_array(fwnode, "reg", reg, ARRAY_SIZE(reg));
>  	if (ret)
>  		return ret;

Does this cause master registration to fail on ACPI systems?

Previously, of_populate_i3c_bus() safely ignored ACPI systems because
dev->of_node was NULL. Now, fwnode_populate_i3c_bus() retrieves the ACPI
fwnode and iterates through its child devices.

For each child, this unconditionally attempts to read the OF-specific reg
property. Since ACPI defines resources via _CRS and _ADR rather than a
reg array, this read will fail and return an error.

This error then propagates up and aborts the entire i3c_master_register()
process. I noticed this regression is fixed later in the patch series by
commit e979566482d52 (i3c: master: Support ACPI enumeration of child
devices), but I am pointing it out here as it temporarily breaks
bisectability for ACPI platforms.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260423085718.70762-1-akhilrajeev@nvidia.com?part=3

  reply	other threads:[~2026-04-23 20:08 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23  8:56 [PATCH v3 00/13] Support ACPI and SETAASA device discovery Akhil R
2026-04-23  8:56 ` Akhil R
2026-04-23  8:57 ` [PATCH v3 01/13] dt-bindings: i3c: Add mipi-i3c-static-method to support SETAASA Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-23 11:23   ` sashiko-bot
2026-05-05 21:32     ` Rob Herring
2026-05-05 22:17       ` Guenter Roeck
2026-05-05 23:12         ` Rob Herring
2026-04-23  8:57 ` [PATCH v3 02/13] ACPICA: Read LVR from the I2C resource descriptor Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-23 19:35   ` sashiko-bot
2026-04-23  8:57 ` [PATCH v3 03/13] i3c: master: Use unified device property interface Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-23 20:08   ` sashiko-bot [this message]
2026-04-23  8:57 ` [PATCH v3 04/13] i3c: master: Support ACPI enumeration of child devices Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-23 22:11   ` sashiko-bot
2026-04-23  8:57 ` [PATCH v3 05/13] i3c: master: Add support for devices using SETAASA Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-23 22:36   ` sashiko-bot
2026-04-23  8:57 ` [PATCH v3 06/13] i3c: master: Add support for devices without PID Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-23 23:01   ` sashiko-bot
2026-04-23  8:57 ` [PATCH v3 07/13] i3c: master: match I3C device through DT and ACPI Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-23 23:27   ` sashiko-bot
2026-04-23  8:57 ` [PATCH v3 08/13] i3c: dw-i3c-master: Add SETAASA as supported CCC Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-23  8:57 ` [PATCH v3 09/13] i3c: dw-i3c-master: Add a quirk to skip clock and reset Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-24  0:18   ` sashiko-bot
2026-04-23  8:57 ` [PATCH v3 10/13] i3c: dw-i3c-master: Add ACPI ID for Tegra410 Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-24  0:34   ` sashiko-bot
2026-04-23  8:57 ` [PATCH v3 11/13] hwmon: spd5118: Remove 16-bit addressing Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-24  1:03   ` sashiko-bot
2026-04-23  8:57 ` [PATCH v3 12/13] hwmon: spd5118: Add I3C support Akhil R
2026-04-23  8:57   ` Akhil R
2026-04-24  3:08   ` sashiko-bot
2026-04-23  8:57 ` [PATCH v3 13/13] arm64: defconfig: Enable I3C and SPD5118 hwmon Akhil R
2026-04-23  8:57   ` 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=20260423200835.5A10FC2BCAF@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.