From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI/pwrctrl: lock device when calling device_is_bound()
Date: Mon, 18 May 2026 10:45:29 +0000 [thread overview]
Message-ID: <20260518104530.57CE6C2BCB8@smtp.kernel.org> (raw)
In-Reply-To: <20260518100700.47581-1-bartosz.golaszewski@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] If a device fails to power on (or is probe deferred), its successfully powered-on children and previous siblings within its subtree are not powered off, causing a resource leak.
--
commit 9be02f191b459f8fb2b5eb9ee177a3aa7076d6f1
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
PCI/pwrctrl: lock device when calling device_is_bound()
This commit adds device locking around device_is_bound() calls in the
PCI power control core to satisfy its kerneldoc requirements.
> diff --git a/drivers/pci/pwrctrl/core.c b/drivers/pci/pwrctrl/core.c
> index 97cff5b8ca885..cd08d590483b8 100644
> --- a/drivers/pci/pwrctrl/core.c
> +++ b/drivers/pci/pwrctrl/core.c
[ ... ]
> @@ -205,7 +207,7 @@ static int __pci_pwrctrl_power_on_device(struct device *dev)
> static int pci_pwrctrl_power_on_device(struct device_node *np)
> {
> struct platform_device *pdev;
> - int ret;
> + int ret = 0;
>
> for_each_available_child_of_node_scoped(np, child) {
> ret = pci_pwrctrl_power_on_device(child);
> @@ -217,12 +219,14 @@ static int pci_pwrctrl_power_on_device(struct device_node *np)
> if (!pdev)
> return 0;
>
> - if (device_is_bound(&pdev->dev)) {
> - ret = __pci_pwrctrl_power_on_device(&pdev->dev);
> - } else {
> - /* FIXME: Use blocking wait instead of probe deferral */
> - dev_dbg(&pdev->dev, "driver is not bound\n");
> - ret = -EPROBE_DEFER;
> + scoped_guard(device, &pdev->dev) {
> + if (device_is_bound(&pdev->dev)) {
> + ret = __pci_pwrctrl_power_on_device(&pdev->dev);
> + } else {
> + /* FIXME: Use blocking wait instead of probe deferral */
> + dev_dbg(&pdev->dev, "driver is not bound\n");
> + ret = -EPROBE_DEFER;
> + }
> }
>
> platform_device_put(pdev);
This problem wasn't introduced by this patch, but does returning here leak
resources on probe deferral?
If a device fails to power on or is probe deferred, the function returns
the error without reverting the state of the children that were already
successfully powered on in the for_each_available_child_of_node_scoped()
loop above.
The top-level caller pci_pwrctrl_power_on_devices() catches the error and
executes the err_power_off cleanup path, but that path only cleans up fully
successful top-level sibling trees up to the failing node. It appears to
skip the partially-powered subtree of the failing node itself.
Since probe deferrals are a normal and frequently repeated process during
system boot, could these leaked refcounts accumulate and eventually cause
resource exhaustion?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260518100700.47581-1-bartosz.golaszewski@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-05-18 10:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 10:07 [PATCH] PCI/pwrctrl: lock device when calling device_is_bound() Bartosz Golaszewski
2026-05-18 10:29 ` Manivannan Sadhasivam
2026-05-18 10:45 ` sashiko-bot [this message]
2026-05-18 22:32 ` Bjorn Helgaas
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=20260518104530.57CE6C2BCB8@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=linux-pci@vger.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