031-0002-PCI-iproc-Free-resource-list-after-registration.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From ef07991a95de76b07594448c3521361831ec2cfe Mon Sep 17 00:00:00 2001
  2. From: Hauke Mehrtens <hauke@hauke-m.de>
  3. Date: Sun, 24 May 2015 22:37:03 +0200
  4. Subject: [PATCH 2/2] PCI: iproc: Free resource list after registration
  5. The resource list is only used in the setup process and was never freed.
  6. pci_add_resource() allocates a memory area to store the list item.
  7. Fix the memory leak.
  8. Tested-by: Ray Jui <rjui@broadcom.com>
  9. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  10. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
  11. Reviewed-by: Ray Jui <rjui@broadcom.com>
  12. ---
  13. drivers/pci/host/pcie-iproc-bcma.c | 8 ++++----
  14. drivers/pci/host/pcie-iproc-platform.c | 8 ++++----
  15. 2 files changed, 8 insertions(+), 8 deletions(-)
  16. --- a/drivers/pci/host/pcie-iproc-bcma.c
  17. +++ b/drivers/pci/host/pcie-iproc-bcma.c
  18. @@ -65,12 +65,12 @@ static int iproc_pcie_bcma_probe(struct
  19. pcie->map_irq = iproc_pcie_bcma_map_irq;
  20. ret = iproc_pcie_setup(pcie, &res);
  21. - if (ret) {
  22. + if (ret)
  23. dev_err(pcie->dev, "PCIe controller setup failed\n");
  24. - return ret;
  25. - }
  26. - return 0;
  27. + pci_free_resource_list(&res);
  28. +
  29. + return ret;
  30. }
  31. static void iproc_pcie_bcma_remove(struct bcma_device *bdev)
  32. --- a/drivers/pci/host/pcie-iproc-platform.c
  33. +++ b/drivers/pci/host/pcie-iproc-platform.c
  34. @@ -72,12 +72,12 @@ static int iproc_pcie_pltfm_probe(struct
  35. pcie->map_irq = of_irq_parse_and_map_pci;
  36. ret = iproc_pcie_setup(pcie, &res);
  37. - if (ret) {
  38. + if (ret)
  39. dev_err(pcie->dev, "PCIe controller setup failed\n");
  40. - return ret;
  41. - }
  42. - return 0;
  43. + pci_free_resource_list(&res);
  44. +
  45. + return ret;
  46. }
  47. static int iproc_pcie_pltfm_remove(struct platform_device *pdev)