Re: [PATCH v4] PCI: imx6: fix resource leaks in probe error paths
From: Manivannan Sadhasivam
Date: Wed Sep 02 2026 - 03:59:36 EST
On Mon, Aug 24, 2026 at 11:04:54PM +0800, Zhijian Han wrote:
> imx_pcie_probe() leaks both pwrctrl devices and power domains on failure:
>
> - imx_pcie_attach_pd() attaches the "pcie" and "pcie_phy" power domains
> and adds device links to them, but nothing detaches the domains on
> probe failure or deferral, so they leak.
>
> - A failure of devm_pm_runtime_set_active_enabled() returns directly
> without destroying the pwrctrl devices.
>
> - A partial failure inside imx_pcie_attach_pd() leaks the power domains
> that were already attached.
>
> Add imx_pcie_detach_pd() to detach the power domains in reverse order of
> acquisition and call it from the probe error paths. Add
> DL_FLAG_AUTOREMOVE_CONSUMER to the device links so the driver core
> removes them automatically when probe fails, instead of tracking and
> deleting them manually.
>
> Reported-by: sashiko-bot@xxxxxxxxxx
> Link: https://lore.kernel.org/all/20260822013640.182C01F000E9@xxxxxxxxxxxxxxx/
> Fixes: 2c5768344f88 ("PCI: imx6: Move pci_pwrctrl_create_devices() to imx_pcie_probe()")
> Signed-off-by: Zhijian Han <hanzhijian1991@xxxxxxxxx>
Frank, Richard, can I get your review for this patch?
- Mani