[PATCH v4] PCI: imx6: fix resource leaks in probe error paths
Hongxing Zhu
hongxing.zhu at nxp.com
Wed Sep 2 01:04:14 PDT 2026
> -----Original Message-----
> From: Manivannan Sadhasivam <mani at kernel.org>
> Sent: Wednesday, September 2, 2026 3:53 PM
> To: Hongxing Zhu <hongxing.zhu at nxp.com>; Frank Li <frank.li at nxp.com>;
> Zhijian Han <hanzhijian1991 at gmail.com>
> Cc: Hongxing Zhu <hongxing.zhu at nxp.com>; Lucas Stach
> <l.stach at pengutronix.de>; Lorenzo Pieralisi <lpieralisi at kernel.org>; Krzysztof
> Wilczyński <kwilczynski at kernel.org>; Bjorn Helgaas <bhelgaas at google.com>;
> Frank Li <frank.li at nxp.com>; Sascha Hauer <s.hauer at pengutronix.de>; Rob
> Herring <robh at kernel.org>; Pengutronix Kernel Team
> <kernel at pengutronix.de>; Fabio Estevam <festevam at gmail.com>; linux-
> pci at vger.kernel.org; linux-arm-kernel at lists.infradead.org;
> imx at lists.linux.dev; linux-kernel at vger.kernel.org; sashiko-bot at kernel.org
> Subject: Re: [PATCH v4] PCI: imx6: fix resource leaks in probe error paths
>
> 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 at kernel.org
> > Link:
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore
> > .kernel.org%2Fall%2F20260822013640.182C01F000E9%40smtp.kernel.org%2
> F&d
> >
> ata=05%7C02%7Chongxing.zhu%40nxp.com%7C8285e77d3eaf45f25a0608df08
> c73e1
> >
> 2%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6392393239841792
> 60%7CUn
> >
> known%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwM
> CIsIlAiOi
> >
> JXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=gcw
> b63Hn
> > dHcOrDQnwD37rUN%2F0EUDcnIZOOGrZ7Ylzio%3D&reserved=0
> > Fixes: 2c5768344f88 ("PCI: imx6: Move pci_pwrctrl_create_devices() to
> > imx_pcie_probe()")
> > Signed-off-by: Zhijian Han <hanzhijian1991 at gmail.com>
>
> Frank, Richard, can I get your review for this patch?
Apologies for missing this earlier.
Reviewed-by: Richard Zhu <hongxing.zhu at nxp.com>
Best Regards
Richard Zhu
>
> - Mani
More information about the linux-arm-kernel
mailing list