]> git.karo-electronics.de Git - linux-beck.git/commitdiff
PCI: iproc: Free resource list after registration
authorHauke Mehrtens <hauke@hauke-m.de>
Sun, 24 May 2015 20:37:03 +0000 (22:37 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 27 May 2015 23:34:05 +0000 (18:34 -0500)
The resource list is only used in the setup process and was never freed.
pci_add_resource() allocates a memory area to store the list item.

Fix the memory leak.

Tested-by: Ray Jui <rjui@broadcom.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Ray Jui <rjui@broadcom.com>
drivers/pci/host/pcie-iproc-bcma.c
drivers/pci/host/pcie-iproc-platform.c

index 7a412a145b5188a6aa95ae6e8329cdfdeff915e7..96a7d999fd5e1efad1963925e0c06dd0eb5075f3 100644 (file)
@@ -65,12 +65,12 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev)
        pcie->map_irq = iproc_pcie_bcma_map_irq;
 
        ret = iproc_pcie_setup(pcie, &res);
-       if (ret) {
+       if (ret)
                dev_err(pcie->dev, "PCIe controller setup failed\n");
-               return ret;
-       }
 
-       return 0;
+       pci_free_resource_list(&res);
+
+       return ret;
 }
 
 static void iproc_pcie_bcma_remove(struct bcma_device *bdev)
index c5fe4c1609720194923ec149d1b7b96b042380b2..9aedc8eb2c6eaa3ffcb29dc562171f9a75161e52 100644 (file)
@@ -72,12 +72,12 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
        pcie->map_irq = of_irq_parse_and_map_pci;
 
        ret = iproc_pcie_setup(pcie, &res);
-       if (ret) {
+       if (ret)
                dev_err(pcie->dev, "PCIe controller setup failed\n");
-               return ret;
-       }
 
-       return 0;
+       pci_free_resource_list(&res);
+
+       return ret;
 }
 
 static int iproc_pcie_pltfm_remove(struct platform_device *pdev)