[PATCH] PCI: imx6: fix pwrctrl device leak on PM runtime setup failure

hanzhijian posted 1 patch 1 month, 1 week ago
drivers/pci/controller/dwc/pci-imx6.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] PCI: imx6: fix pwrctrl device leak on PM runtime setup failure
Posted by hanzhijian 1 month, 1 week ago
In imx_pcie_probe(), after pci_pwrctrl_create_devices() creates the
pwrctrl devices, the error paths for imx_add_pcie_ep() and
dw_pcie_host_init() both jump to err_pwrctrl_destroy to tear them down.
However, the error path for devm_pm_runtime_set_active_enabled() returns
directly, leaking the pwrctrl devices.

Jump to err_pwrctrl_destroy instead so the pwrctrl devices are cleaned
up on this error path too.

Signed-off-by: hanzhijian <hanzhijian1991@gmail.com>
---
 drivers/pci/controller/dwc/pci-imx6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index 39790e66b..616c42932 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -1975,7 +1975,7 @@ static int imx_pcie_probe(struct platform_device *pdev)
 			pm_runtime_no_callbacks(dev);
 			ret = devm_pm_runtime_set_active_enabled(dev);
 			if (ret < 0)
-				return ret;
+				goto err_pwrctrl_destroy;
 		}
 
 		if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_SKIP_L23_READY))
-- 
2.43.0
Re: [PATCH] PCI: imx6: fix pwrctrl device leak on PM runtime setup failure
Posted by Manivannan Sadhasivam 3 weeks, 5 days ago
On Sat, 22 Aug 2026 09:22:05 +0800, hanzhijian wrote:
> In imx_pcie_probe(), after pci_pwrctrl_create_devices() creates the
> pwrctrl devices, the error paths for imx_add_pcie_ep() and
> dw_pcie_host_init() both jump to err_pwrctrl_destroy to tear them down.
> However, the error path for devm_pm_runtime_set_active_enabled() returns
> directly, leaking the pwrctrl devices.
> 
> Jump to err_pwrctrl_destroy instead so the pwrctrl devices are cleaned
> up on this error path too.
> 
> [...]

Applied, thanks!

[1/1] PCI: imx6: fix pwrctrl device leak on PM runtime setup failure
      commit: 0031f76f73b86f711d0e4e95a967aea1821fb867

Best regards,
-- 
மணிவண்ணன் சதாசிவம்