From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: robh@kernel.org, lee@kernel.org, imx@lists.linux.dev,
dri-devel@lists.freedesktop.org, Frank.Li@kernel.org,
devicetree@vger.kernel.org, mfd@lists.linux.dev,
conor+dt@kernel.org
Subject: Re: [PATCH v3 15/20] drm/xe/i2c: use platform_device_set_fwnode()
Date: Tue, 07 Jul 2026 13:25:02 +0000 [thread overview]
Message-ID: <20260707132503.490C81F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260706-pdev-fwnode-ref-v3-15-1ff028e33779@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing cancel_work_sync() in the xe_i2c teardown path leads to a Use-After-Free of the device structure.
--
commit 1fdde54b64291aceacb95c2a267bee6b6609b500
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drm/xe/i2c: use platform_device_set_fwnode()
This commit encapsulates the assignment of the firmware node for dynamically
allocated platform devices with the provided helper ahead of reworking the
reference counting logic.
> diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c
> index 706783863d07d..af4ebd93ad8e6 100644
> --- a/drivers/gpu/drm/xe/xe_i2c.c
> +++ b/drivers/gpu/drm/xe/xe_i2c.c
[ ... ]
> @@ -123,7 +123,7 @@ static int xe_i2c_register_adapter(struct xe_i2c *i2c)
> }
>
> pdev->dev.parent = i2c->drm_dev;
> - pdev->dev.fwnode = fwnode;
> + platform_device_set_fwnode(pdev, fwnode);
> i2c->adapter_node = fwnode;
> i2c->pdev = pdev;
[Severity: High]
This is a pre-existing issue, but does the teardown path for this adapter
need a cancel_work_sync() call?
The I2C adapter registration during xe_i2c_probe() triggers a
BUS_NOTIFY_ADD_DEVICE notification, which schedules i2c->work. If the device
is unbound before this background work completes, xe_i2c_remove() is called:
static void xe_i2c_remove(void *data)
{
struct xe_i2c *i2c = data;
unsigned int i;
for (i = 0; i < XE_I2C_MAX_CLIENTS; i++)
i2c_unregister_device(i2c->client[i]);
bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier);
xe_i2c_unregister_adapter(i2c);
xe_i2c_remove_irq(i2c);
}
Since xe_i2c_remove() unregisters the notifier and adapter but fails to call
cancel_work_sync(&i2c->work), could the scheduled work execute after the
struct xe_i2c memory is freed?
This appears to leave a window for a use-after-free when unbinding the driver,
as the delayed work might dereference the freed i2c pointer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=15
next prev parent reply other threads:[~2026-07-07 13:25 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
2026-07-06 12:44 ` [PATCH v3 01/20] powerpc/powermac: fix OF node refcount Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node() Bartosz Golaszewski
2026-07-06 14:39 ` Manuel Ebner
2026-07-06 14:48 ` Manuel Ebner
2026-07-06 15:49 ` Andy Shevchenko
2026-07-06 17:26 ` Mark Brown
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 03/20] driver core: platform: provide platform_device_set_fwnode() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 04/20] driver core: platform: provide platform_device_set_of_node_from_dev() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 06/20] of: platform: use platform_device_set_of_node() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 07/20] powerpc/powermac: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 08/20] i2c: pxa-pci: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 09/20] iommu/fsl: " Bartosz Golaszewski
2026-07-06 14:51 ` Frank Li
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 10/20] net: bcmgenet: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 11/20] pmdomain: imx: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 12/20] mfd: tps6586: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 13/20] slimbus: qcom-ngd-ctrl: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 14/20] net: mv643xx: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 15/20] drm/xe/i2c: use platform_device_set_fwnode() Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot [this message]
2026-07-06 12:44 ` [PATCH v3 16/20] platform/surface: gpe: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 17/20] usb: chipidea: use platform_device_set_of_node_from_dev() Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 18/20] usb: musb: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 19/20] reset: rzg2l: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 20/20] driver core: platform: count references to all kinds of firmware nodes Bartosz Golaszewski
2026-07-07 13:25 ` 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=20260707132503.490C81F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=imx@lists.linux.dev \
--cc=lee@kernel.org \
--cc=mfd@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sashiko-reviews@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox