From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 4/5] driver core: platform: unify release path
Date: Thu, 16 Jul 2026 13:02:03 +0000 [thread overview]
Message-ID: <20260716130203.8373A1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260716-swnode-remove-on-dev-unreg-v8-4-5c2b8cc38c28@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Dereferencing a freed primary software node during platform device release, leading to a Use-After-Free and possible double-put.
--
--- Patch [4]: [PATCH v8 4/5] driver core: platform: unify release path ---
commit a4c9de720c7986b23ccb07ee951d4a99f15666ec
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
driver core: platform: unify release path
With no drivers that manually assign software nodes to platform devices
created with platform_device_alloc(), we can now unify the release path
and remove platform_device_release_full().
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index fb57d487a6c2a..66f9ec73d47e9 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
[ ... ]
> @@ -599,19 +599,19 @@ static void platform_device_release(struct device *dev)
> struct platform_object *pa = container_of(dev, struct platform_object,
> pdev.dev);
>
> - fwnode_handle_put(pa->pdev.dev.fwnode);
> + device_remove_software_node(dev);
> + /*
> + * If the primary firmware node is a software node, its reference count
> + * was already decreased by the call to device_remove_software_node().
> + */
> + if (!is_software_node(dev_fwnode(dev)))
[Severity: High]
Does this check result in a use-after-free of the primary software node?
If a platform device is registered with a primary software node (for example
via platform_device_register_full()), dev->fwnode points to it.
During device release, device_remove_software_node() retrieves the primary
software node and drops the reference, potentially freeing the node:
device_remove_software_node()
swnode_put(swnode);
Because dev->fwnode is primary, set_secondary_fwnode(dev, NULL) inside
device_remove_software_node() only clears the secondary pointer, leaving
dev->fwnode still pointing to the freed primary node.
The subsequent call to is_software_node(dev_fwnode(dev)) would then
dereference this dangling pointer.
> + fwnode_handle_put(pa->pdev.dev.fwnode);
> kfree(pa->pdev.dev.platform_data);
> kfree(pa->pdev.mfd_cell);
> kfree(pa->pdev.resource);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260716-swnode-remove-on-dev-unreg-v8-0-5c2b8cc38c28@oss.qualcomm.com?part=4
next prev parent reply other threads:[~2026-07-16 13:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 12:31 [PATCH v8 0/5] driver core: unify the release path for dynamically allocated platform devices Bartosz Golaszewski
2026-07-16 12:31 ` [PATCH v8 1/5] driver core: platform: amend the API contract for fwnode setters Bartosz Golaszewski
2026-07-16 12:39 ` sashiko-bot
2026-07-17 11:29 ` Danilo Krummrich
2026-07-16 12:31 ` [PATCH v8 2/5] platform/surface: gpe: use platform_device_register_full() Bartosz Golaszewski
2026-07-16 12:31 ` [PATCH v8 3/5] drm/xe/i2c: use device_create_managed_software_node() Bartosz Golaszewski
2026-07-16 12:31 ` [PATCH v8 4/5] driver core: platform: unify release path Bartosz Golaszewski
2026-07-16 13:02 ` sashiko-bot [this message]
2026-07-16 12:31 ` [PATCH v8 5/5] driver core: platform: tests: add test cases for correct swnode removal Bartosz Golaszewski
2026-07-16 12:51 ` sashiko-bot
2026-07-19 23:08 ` [PATCH v8 0/5] driver core: unify the release path for dynamically allocated platform devices Danilo Krummrich
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=20260716130203.8373A1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=dri-devel@lists.freedesktop.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 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.