Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: iproc: Free resource list after registration

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>

authored by

Hauke Mehrtens and committed by
Bjorn Helgaas
ef07991a 18c4342a

+8 -8
+4 -4
drivers/pci/host/pcie-iproc-bcma.c
··· 65 65 pcie->map_irq = iproc_pcie_bcma_map_irq; 66 66 67 67 ret = iproc_pcie_setup(pcie, &res); 68 - if (ret) { 68 + if (ret) 69 69 dev_err(pcie->dev, "PCIe controller setup failed\n"); 70 - return ret; 71 - } 72 70 73 - return 0; 71 + pci_free_resource_list(&res); 72 + 73 + return ret; 74 74 } 75 75 76 76 static void iproc_pcie_bcma_remove(struct bcma_device *bdev)
+4 -4
drivers/pci/host/pcie-iproc-platform.c
··· 72 72 pcie->map_irq = of_irq_parse_and_map_pci; 73 73 74 74 ret = iproc_pcie_setup(pcie, &res); 75 - if (ret) { 75 + if (ret) 76 76 dev_err(pcie->dev, "PCIe controller setup failed\n"); 77 - return ret; 78 - } 79 77 80 - return 0; 78 + pci_free_resource_list(&res); 79 + 80 + return ret; 81 81 } 82 82 83 83 static int iproc_pcie_pltfm_remove(struct platform_device *pdev)