From: sashiko-bot@kernel.org
To: hanzhijian <hanzhijian1991@gmail.com>
Cc: linux-pci@vger.kernel.org, imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v3] PCI: imx6: fix resource leaks in probe error paths
Date: Mon, 24 Aug 2026 08:09:51 +0000 [thread overview]
Message-ID: <20260824080952.040ED1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260824075512.3386898-1-hanzhijian1991@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Endpoint setup failure permanently leaks host resources and ignores initialization errors from imx_pcie_host_init().
--
--- Patch [1]: [PATCH v3] PCI: imx6: fix resource leaks in probe error paths ---
commit a77762d63857f9ca84de44552a329e64c4d4176e
Author: hanzhijian <hanzhijian1991@gmail.com>
PCI: imx6: fix resource leaks in probe error paths
This commit fixes resource leaks in imx_pcie_probe() by introducing
imx_pcie_detach_pd() to properly release power domains and device links
when probing fails. It ensures these resources are cleaned up in reverse
order of acquisition.
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..467006d839a60 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
[ ... ]
> @@ -1956,8 +1987,10 @@ static int imx_pcie_probe(struct platform_device *pdev)
> return ret;
>
> ret = pci_pwrctrl_create_devices(dev);
> - if (ret)
> + if (ret) {
> + imx_pcie_detach_pd(imx_pcie);
> return dev_err_probe(dev, ret, "failed to create pwrctrl devices\n");
> + }
>
> pci->use_parent_dt_ranges = true;
> if (imx_pcie->drvdata->mode == DW_PCIE_EP_TYPE) {
[Severity: High]
This is a pre-existing issue, but does imx_add_pcie_ep() leak host resources
on failure, and ignore initialization errors?
Looking at the implementation of imx_add_pcie_ep():
drivers/pci/controller/dwc/pci-imx6.c:imx_add_pcie_ep() {
...
imx_pcie_host_init(pp);
...
ret = dw_pcie_ep_init(ep);
if (ret) {
dev_err(dev, "failed to initialize endpoint\n");
return ret;
}
...
}
The return value of imx_pcie_host_init() is completely ignored, meaning errors
during clock, regulator, or PHY state initialization aren't caught. If the
hardware fails to power on, the driver proceeds to initialize the endpoint
anyway.
Additionally, if dw_pcie_ep_init() fails, the function returns directly
without calling imx_pcie_host_exit(). Doesn't this bypass teardown and
permanently leak all acquired host resources?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824075512.3386898-1-hanzhijian1991@gmail.com?part=1
next prev parent reply other threads:[~2026-08-24 8:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-23 1:11 [PATCH] PCI: imx6: fix power domain leak on probe failure hanzhijian
2026-08-23 1:24 ` sashiko-bot
2026-08-23 7:11 ` [PATCH v2] PCI: imx6: fix resource leaks in probe error paths hanzhijian
2026-08-23 7:27 ` sashiko-bot
2026-08-24 7:55 ` [PATCH v3] " hanzhijian
2026-08-24 8:09 ` sashiko-bot [this message]
2026-08-24 11:01 ` Markus Elfring
2026-08-24 14:42 ` Frank Li
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=20260824080952.040ED1F00A3D@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