]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PCI: xilinx-cpm: Fix IRQ domain leak in error path of probe
authorThippeswamy Havalige <thippeswamy.havalige@amd.com>
Mon, 24 Feb 2025 15:50:22 +0000 (21:20 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:30:56 +0000 (14:30 +0200)
[ Upstream commit 57b0302240741e73fe51f88404b3866e0d2933ad ]

The IRQ domain allocated for the PCIe controller is not freed if
resource_list_first_type() returns NULL, leading to a resource leak.

This fix ensures properly cleaning up the allocated IRQ domain in
the error path.

Fixes: 49e427e6bdd1 ("Merge branch 'pci/host-probe-refactor'")
Signed-off-by: Thippeswamy Havalige <thippeswamy.havalige@amd.com>
[kwilczynski: added missing Fixes: tag, refactored to use one of the goto labels]
Signed-off-by: Krzysztof WilczyƄski <kwilczynski@kernel.org>
Link: https://lore.kernel.org/r/20250224155025.782179-2-thippeswamy.havalige@amd.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pci/controller/pcie-xilinx-cpm.c

index 67937facd90cdcde68060f21060d4e0acf49af30..1b8366fa9f7831ca6dd11089bcdb4cd4f5fd7e31 100644 (file)
@@ -556,13 +556,15 @@ static int xilinx_cpm_pcie_probe(struct platform_device *pdev)
                return err;
 
        bus = resource_list_first_type(&bridge->windows, IORESOURCE_BUS);
-       if (!bus)
-               return -ENODEV;
+       if (!bus) {
+               err = -ENODEV;
+               goto err_free_irq_domains;
+       }
 
        err = xilinx_cpm_pcie_parse_dt(port, bus->res);
        if (err) {
                dev_err(dev, "Parsing DT failed\n");
-               goto err_parse_dt;
+               goto err_free_irq_domains;
        }
 
        xilinx_cpm_pcie_init_port(port);
@@ -586,7 +588,7 @@ err_host_bridge:
        xilinx_cpm_free_interrupts(port);
 err_setup_irq:
        pci_ecam_free(port->cfg);
-err_parse_dt:
+err_free_irq_domains:
        xilinx_cpm_free_irq_domains(port);
        return err;
 }