PCI: xilinx: Free bridge resource list on failure

This change “PCI: xilinx: Free bridge resource list on failure” (commit c41be7a) in Linux kernel is authored by Bjorn Helgaas <bhelgaas [at] google.com> on Tue May 31 11:49:14 2016 -0500.

Description of "PCI: xilinx: Free bridge resource list on failure"

The change “PCI: xilinx: Free bridge resource list on failure” introduces changes as follows.

PCI: xilinx: Free bridge resource list on failure

of_pci_get_host_bridge_resources() allocates a list of resources for host
bridge windows.  If we fail after allocating that list, free it before we
return error.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Linux kernel releases containing commit c41be7a

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "PCI: xilinx: Free bridge resource list on failure"

There are 11 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/pci/host/pcie-xilinx.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
 
diff --git a/drivers/pci/host/pcie-xilinx.c b/drivers/pci/host/pcie-xilinx.c
index 65f0fe0c2eaf..5c456db47c49 100644
--- a/drivers/pci/host/pcie-xilinx.c
+++ b/drivers/pci/host/pcie-xilinx.c
@@ -660,7 +660,6 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
 	struct xilinx_pcie_port *port;
 	struct device *dev = &pdev->dev;
 	struct pci_bus *bus;
-
 	int err;
 	resource_size_t iobase = 0;
 	LIST_HEAD(res);
@@ -696,8 +695,10 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
 	}
 	bus = pci_create_root_bus(&pdev->dev, 0,
 				  &xilinx_pcie_ops, port, &res);
-	if (!bus)
-		return -ENOMEM;
+	if (!bus) {
+		err = -ENOMEM;
+		goto error;
+	}
 
 #ifdef CONFIG_PCI_MSI
 	xilinx_pcie_msi_chip.dev = port->dev;
@@ -712,6 +713,10 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, port);
 
 	return 0;
+
+error:
+	pci_free_resource_list(&res);
+	return err;
 }
 
 /**

The commit for this change in Linux stable tree is c41be7a (patch).

Last modified: 2020/02/09