From: sashiko-bot@kernel.org
To: "Zhijian Han" <hanzhijian1991@gmail.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v5] PCI: imx6: fix resource leaks in probe error paths
Date: Wed, 02 Sep 2026 17:02:33 +0000 [thread overview]
Message-ID: <20260902170234.6D37F1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260902164313.2901302-1-hanzhijian1991@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Replacing DL_FLAG_STATELESS with DL_FLAG_AUTOREMOVE_CONSUMER for device links to virtual PM domain devices creates managed links that violate the driver core state machine, triggering a WARN_ON during successful probe.
--
commit 36162fbf1662cbc9312c01c7d2c2113d6c77e624
Author: Zhijian Han <hanzhijian1991@gmail.com>
PCI: imx6: fix resource leaks in probe error paths
This commit fixes resource leaks involving pwrctrl devices and power domains
in the imx_pcie_probe() error paths. It adds a devm action to detach the
power domains and replaces the stateless device link flag with an autoremove
consumer flag so links are cleaned up automatically.
Link: https://lore.kernel.org/all/20260822013640.182C01F000E9@smtp.kernel.org/
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 39790e66b98dc..ec8339e03d584 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
[ ... ]
> @@ -655,24 +672,30 @@ static int imx_pcie_attach_pd(struct device *dev)
> if (!imx_pcie->pd_pcie)
> return 0;
> link = device_link_add(dev, imx_pcie->pd_pcie,
> - DL_FLAG_STATELESS |
> DL_FLAG_PM_RUNTIME |
> - DL_FLAG_RPM_ACTIVE);
> + DL_FLAG_RPM_ACTIVE |
> + DL_FLAG_AUTOREMOVE_CONSUMER);
[Severity: High]
Does changing this link from stateless to managed violate the driver core
state machine for virtual PM domain devices?
Virtual PM domain devices created on the genpd bus never bind to drivers,
so their driver status remains DL_DEV_NO_DRIVER. Because of this,
device_link_add() will initialize a managed link to DL_STATE_DORMANT.
When the consumer device successfully completes its probe, the driver core
calls device_links_driver_bound(). That function iterates over all managed
supplier links and evaluates:
WARN_ON(link->status != DL_STATE_CONSUMER_PROBE)
Since this link is dormant, won't this trigger the WARN_ON and turn a
successful normal boot sequence into a kernel panic on systems with
panic_on_warn enabled?
> if (!link) {
> dev_err(dev, "Failed to add device_link to pcie pd\n");
> + imx_pcie_detach_pd(imx_pcie);
> return -EINVAL;
> }
>
> imx_pcie->pd_pcie_phy = dev_pm_domain_attach_by_name(dev, "pcie_phy");
> - if (IS_ERR(imx_pcie->pd_pcie_phy))
> - return PTR_ERR(imx_pcie->pd_pcie_phy);
> + if (IS_ERR(imx_pcie->pd_pcie_phy)) {
> + int ret = PTR_ERR(imx_pcie->pd_pcie_phy);
> +
> + imx_pcie_detach_pd(imx_pcie);
> + return ret;
> + }
>
> link = device_link_add(dev, imx_pcie->pd_pcie_phy,
> - DL_FLAG_STATELESS |
> DL_FLAG_PM_RUNTIME |
> - DL_FLAG_RPM_ACTIVE);
> + DL_FLAG_RPM_ACTIVE |
> + DL_FLAG_AUTOREMOVE_CONSUMER);
[Severity: High]
This has the same issue as the pcie power domain link creation above.
Since DL_FLAG_AUTOREMOVE_CONSUMER implies a managed link, should these
links for virtual PM domain devices remain DL_FLAG_STATELESS to avoid
the WARN_ON during device_links_driver_bound()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260902164313.2901302-1-hanzhijian1991@gmail.com?part=1
prev parent reply other threads:[~2026-09-02 17:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 16:43 [PATCH v5] PCI: imx6: fix resource leaks in probe error paths Zhijian Han
2026-09-02 17:02 ` 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=20260902170234.6D37F1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=hanzhijian1991@gmail.com \
--cc=imx@lists.linux.dev \
--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