From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: Frank.Li@kernel.org, dri-devel@lists.freedesktop.org,
robh@kernel.org, conor+dt@kernel.org, imx@lists.linux.dev,
devicetree@vger.kernel.org
Subject: Re: [PATCH v2 10/19] pmdomain: imx: use platform_device_set_of_node()
Date: Tue, 30 Jun 2026 09:18:39 +0000 [thread overview]
Message-ID: <20260630091840.013AA1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260629-pdev-fwnode-ref-v2-10-8abe2513f96e@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] OF node reference leak introduced by replacing direct assignment with platform_device_set_of_node().
Pre-existing issues:
- [High] Missing cleanup of dynamically allocated child platform devices causes Use-After-Free on probe error and remove paths.
--
commit f80cbf40e80bb2e67469b487f2abcc9652b28cb1
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
pmdomain: imx: use platform_device_set_of_node()
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
> diff --git a/drivers/pmdomain/imx/gpc.c b/drivers/pmdomain/imx/gpc.c
> index 42e50c9b4fb9f..abca5f449a226 100644
> --- a/drivers/pmdomain/imx/gpc.c
> +++ b/drivers/pmdomain/imx/gpc.c
> @@ -487,8 +487,7 @@ static int imx_gpc_probe(struct platform_device *pdev)
> domain->ipg_rate_mhz = ipg_rate_mhz;
>
> pd_pdev->dev.parent = &pdev->dev;
> - pd_pdev->dev.of_node = of_node_get(np);
> - pd_pdev->dev.fwnode = of_fwnode_handle(np);
> + platform_device_set_of_node(pd_pdev, np);
[Severity: Medium]
Does replacing direct assignment with platform_device_set_of_node()
introduce an OF node reference leak?
In drivers/i2c/busses/i2c-pxa-pci.c:add_i2c_device(), the function acquires
an OF node reference via the for_each_child_of_node iterator and then calls
platform_device_set_of_node(pdev, child) on success.
Before this patch series, pdev->dev.of_node = child directly transferred
ownership of the reference to the platform device, which released it upon
destruction. Because the new helper platform_device_set_of_node()
explicitly increments the reference count internally, and there is no
of_node_put(child) added after the helper call, does this permanently leak
the original iterator reference on both success and error paths?
>
> ret = platform_device_add(pd_pdev);
> if (ret) {
[Severity: High]
This is a pre-existing issue, but does the missing cleanup of dynamically
allocated child platform devices cause a use-after-free on probe error and
remove paths?
In imx_gpc_probe(), child devices (pd_pdev) are dynamically allocated and
registered in a loop. If a subsequent iteration fails and returns here,
the function returns immediately without unregistering the previously added
children.
Furthermore, in imx_gpc_remove(), when using the new device tree binding
(pgc_node is present), it exits without unregistering any child devices.
Since the child devices remain registered, their bound drivers (imx-pgc-pd)
stay active. When the parent devres cleanup frees the regmap, won't any
subsequent power state transition by the active child domains dereference
the freed domain->regmap, resulting in a use-after-free crash?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260629-pdev-fwnode-ref-v2-0-8abe2513f96e@oss.qualcomm.com?part=10
next prev parent reply other threads:[~2026-06-30 9:18 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 9:12 [PATCH v2 00/19] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
2026-06-29 9:12 ` [PATCH v2 01/19] powerpc/powermac: fix OF node refcount Bartosz Golaszewski
2026-06-29 9:12 ` [PATCH v2 02/19] driver core: platform: provide platform_device_set_of_node() Bartosz Golaszewski
2026-06-30 9:18 ` sashiko-bot
2026-06-30 11:37 ` Manuel Ebner
2026-06-30 13:22 ` Bartosz Golaszewski
2026-07-01 15:05 ` Manuel Ebner
2026-06-29 9:12 ` [PATCH v2 03/19] driver core: platform: provide platform_device_set_fwnode() Bartosz Golaszewski
2026-06-29 9:12 ` [PATCH v2 04/19] driver core: platform: provide platform_device_set_of_node_from_dev() Bartosz Golaszewski
2026-06-29 9:12 ` [PATCH v2 05/19] of: platform: use platform_device_set_of_node() Bartosz Golaszewski
2026-06-29 9:12 ` [PATCH v2 06/19] powerpc/powermac: " Bartosz Golaszewski
2026-06-29 9:12 ` [PATCH v2 07/19] i2c: pxa-pci: " Bartosz Golaszewski
2026-06-30 9:18 ` sashiko-bot
2026-06-29 9:12 ` [PATCH v2 08/19] iommu/fsl: " Bartosz Golaszewski
2026-06-29 14:08 ` Frank Li
2026-06-29 9:12 ` [PATCH v2 09/19] net: bcmgenet: " Bartosz Golaszewski
2026-06-29 23:15 ` Jakub Kicinski
2026-06-30 9:18 ` sashiko-bot
2026-06-29 9:12 ` [PATCH v2 10/19] pmdomain: imx: " Bartosz Golaszewski
2026-06-30 9:18 ` sashiko-bot [this message]
2026-06-30 15:27 ` Frank Li
2026-06-29 9:12 ` [PATCH v2 11/19] mfd: tps6586: " Bartosz Golaszewski
2026-06-29 9:12 ` [PATCH v2 12/19] slimbus: qcom-ngd-ctrl: " Bartosz Golaszewski
2026-06-29 9:25 ` Konrad Dybcio
2026-06-29 9:12 ` [PATCH v2 13/19] net: mv643xx: " Bartosz Golaszewski
2026-06-29 23:16 ` Jakub Kicinski
2026-06-29 9:12 ` [PATCH v2 14/19] drm/xe/i2c: use platform_device_set_fwnode() Bartosz Golaszewski
2026-06-30 9:18 ` sashiko-bot
2026-06-29 9:12 ` [PATCH v2 15/19] platform/surface: gpe: " Bartosz Golaszewski
2026-06-29 9:12 ` [PATCH v2 16/19] usb: chipidea: use platform_device_set_of_node_from_dev() Bartosz Golaszewski
2026-06-29 9:12 ` [PATCH v2 17/19] usb: musb: " Bartosz Golaszewski
2026-06-30 9:18 ` sashiko-bot
2026-06-29 9:12 ` [PATCH v2 18/19] reset: rzg2l: " Bartosz Golaszewski
2026-06-29 9:12 ` [PATCH v2 19/19] driver core: platform: count references to all kinds of firmware nodes Bartosz Golaszewski
2026-06-29 16:21 ` Andy Shevchenko
2026-06-30 9:18 ` sashiko-bot
2026-06-29 16:23 ` [PATCH v2 00/19] driver core: count references of the platform device's fwnode, not OF node Andy Shevchenko
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=20260630091840.013AA1F00A3A@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=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