All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: Frank.Li@kernel.org, lee@kernel.org, devicetree@vger.kernel.org,
	dri-devel@lists.freedesktop.org, conor+dt@kernel.org,
	imx@lists.linux.dev, mfd@lists.linux.dev, robh@kernel.org
Subject: Re: [PATCH v3 11/20] pmdomain: imx: use platform_device_set_of_node()
Date: Tue, 07 Jul 2026 13:24:58 +0000	[thread overview]
Message-ID: <20260707132458.9E7371F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260706-pdev-fwnode-ref-v3-11-1ff028e33779@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Child platform devices dynamically added during probe are not unregistered on probe error paths or during driver removal.
- [High] The i.MX GPC power domain driver initializes domains as powered on but does not set GENPD_FLAG_NO_STAY_ON or provide a sync_state callback, causing domains to stay on indefinitely.
--

commit 183445e8048cfd412f98719fae14416614f14176
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);
>  
>  			ret = platform_device_add(pd_pdev);
>  			if (ret) {

[Severity: High]
This isn't a bug introduced by this patch, but I noticed that child platform
devices added in previous loop iterations are not unregistered on this error
path.

If platform_device_add() fails, or if platform_device_alloc() fails earlier
in the loop, imx_gpc_probe() returns immediately. Any successfully added
"imx-pgc-power-domain" devices from previous iterations are left orphaned.

Because these orphaned child devices hold references to the parent's
devm-managed regmap, does this create a use-after-free when the parent's
devres cleanup runs?

The same unregistering step appears to be missing in imx_gpc_remove(), which
skips the cleanup of these dynamically added platform devices entirely when
pgc_node is present.

[Severity: High]
This is also a pre-existing issue, but I noticed a potential problem with how
these domains are initialized.

In imx_pgc_power_domain_probe(), the domains are initialized as powered on
via pm_genpd_init(&domain->base, NULL, false). For OF-based genpd providers,
this sets genpd->stay_on = true.

However, neither imx_gpc_driver nor imx_pgc_power_domain_driver registers a
.sync_state callback, and the domains do not have GENPD_FLAG_NO_STAY_ON set.

Since the stay_on flag is never cleared, will this cause the domains to
remain powered on indefinitely? If regulator_late_cleanup() later disables
the underlying regulators while the domains are still active, could this
lead to hardware malfunctions?

>  				platform_device_put(pd_pdev);
>  				return ret;
>  			}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=11

  reply	other threads:[~2026-07-07 13:24 UTC|newest]

Thread overview: 54+ 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-07 16:05   ` Andy Shevchenko
2026-07-08  7:42     ` Bartosz Golaszewski
2026-07-08 11:11       ` Andy Shevchenko
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 [this message]
2026-07-13 10:29   ` Ulf Hansson
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
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
2026-07-06 13:20 ` ✓ CI.KUnit: success for driver core: count references of the platform device's fwnode, not OF node (rev3) Patchwork
2026-07-06 14:17 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-06 16:01 ` ✓ Xe.CI.FULL: " Patchwork
2026-07-10 14:09 ` [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Greg Kroah-Hartman

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=20260707132458.9E7371F00A3D@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 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.