Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Herve Codina" <herve.codina@bootlin.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v8 2/2] bus: simple-pm-bus: Populate child nodes at probe
Date: Tue, 30 Jun 2026 10:57:01 +0000	[thread overview]
Message-ID: <20260630105701.7D0471F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260630102717.413501-3-herve.codina@bootlin.com>

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

Pre-existing issues:
- [High] Time-of-Check to Time-of-Use (TOCTOU) race with the mutable driver_override sysfs attribute causes state mismatch and resource leaks.
- [High] The driver leaks clock enable counts during removal because pm_runtime_disable() is called without synchronously suspending the device.
--

commit 8879d2bb547d47c5c484809ff15676d13cfec9a8
Author: Herve Codina <herve.codina@bootlin.com>

bus: simple-pm-bus: Populate child nodes at probe

The simple-pm-bus driver didn't populate child devices during probe when used
with busses other than a compatible "simple-pm-bus", confusing fw_devlink.
This commit explicitly populates child nodes during probe for those compatible
devices to ensure proper devlink creation and consumer removal ordering.

> diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c
> index 4b2a793dfbd90..d969bf19a4e95 100644
> --- a/drivers/bus/simple-pm-bus.c
> +++ b/drivers/bus/simple-pm-bus.c

[ ... ]

> @@ -78,7 +80,7 @@ static void simple_pm_bus_remove(struct platform_device *pdev)
>  {
>  	const void *data = of_device_get_match_data(&pdev->dev);
>  
> -	if (device_has_driver_override(&pdev->dev) || data)
> +	if (device_has_driver_override(&pdev->dev))

[Severity: High]
This isn't a bug introduced by this patch, but is it safe to rely on
device_has_driver_override() here during removal?

The driver_override sysfs attribute is mutable. If it is changed by a user
after probe() but before remove(), the control flow in remove() will skip
of_platform_depopulate() and pm_runtime_disable(), causing state mismatches.

If the override is cleared after being set during probe, remove() might
attempt to depopulate children it never populated and disable PM runtime it
never enabled.

Could this rely on the driver's own internal state (like dev_get_drvdata())
instead of checking a mutable sysfs attribute?

>  		return;
>  
>  	dev_dbg(&pdev->dev, "%s\n", __func__);
> @@ -86,7 +88,8 @@ static void simple_pm_bus_remove(struct platform_device *pdev)
>  	if (pdev->dev.of_node)
>  		of_platform_depopulate(&pdev->dev);
>  
> -	pm_runtime_disable(&pdev->dev);
> +	if (!data)
> +		pm_runtime_disable(&pdev->dev);

[Severity: High]
This is a pre-existing issue, but does calling pm_runtime_disable() here
without synchronously suspending the device leak clock enable counts?

of_platform_depopulate() removes the children, which may asynchronously drop
the bus's PM usage counter. Calling pm_runtime_disable() immediately
afterward cancels any pending async suspend requests.

If the parent bus remains RPM_ACTIVE when pm_runtime_disable() completes,
devm will free the clock structures without disabling them, permanently
leaking the clock references.

Should the driver synchronously suspend the device before disabling runtime PM?

>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260630102717.413501-1-herve.codina@bootlin.com?part=2

      reply	other threads:[~2026-06-30 10:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 10:27 [PATCH v8 0/2] lan966x pci device: Add support for SFPs, simple-bus part Herve Codina
2026-06-30 10:27 ` [PATCH v8 1/2] bus: simple-pm-bus: Remove child devices when the bus is unbound Herve Codina
2026-06-30 10:46   ` sashiko-bot
2026-06-30 10:27 ` [PATCH v8 2/2] bus: simple-pm-bus: Populate child nodes at probe Herve Codina
2026-06-30 10:57   ` sashiko-bot [this message]

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=20260630105701.7D0471F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=herve.codina@bootlin.com \
    --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