aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenzo Pieralisi <lorenzo.pieralisi@arm.com>2015-01-27 13:01:45 -0500
committerBjorn Helgaas <bhelgaas@google.com>2015-01-28 18:08:20 -0500
commitd2be00c0fb5ae0794deffcdb0425cd5a8d823db0 (patch)
tree6f0a31e8a236f9278c15b40988f4ea23fbfdc496
parent97bf6af1f928216fd6c5a66e8a57bfa95a659672 (diff)
of/pci: Free resources on failure in of_pci_get_host_bridge_resources()
In the function of_pci_get_host_bridge_resources() if the parsing of ranges fails, previously allocated resources inclusive of bus_range are not freed and are not expected to be freed by the function caller on error return. This patch fixes the issues by adding code that properly frees resources and bus_range before exiting the function with an error return value. Fixes: cbe4097f8ae6 ("of/pci: Add support for parsing PCI host bridge resources from DT") Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Liviu Dudau <liviu.dudau@arm.com> CC: Arnd Bergmann <arnd@arndb.de> CC: Rob Herring <robh+dt@kernel.org>
-rw-r--r--drivers/of/of_pci.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
index 88471d3d98cd..60dc36c865b5 100644
--- a/drivers/of/of_pci.c
+++ b/drivers/of/of_pci.c
@@ -140,6 +140,7 @@ int of_pci_get_host_bridge_resources(struct device_node *dev,
140 unsigned char busno, unsigned char bus_max, 140 unsigned char busno, unsigned char bus_max,
141 struct list_head *resources, resource_size_t *io_base) 141 struct list_head *resources, resource_size_t *io_base)
142{ 142{
143 struct pci_host_bridge_window *window;
143 struct resource *res; 144 struct resource *res;
144 struct resource *bus_range; 145 struct resource *bus_range;
145 struct of_pci_range range; 146 struct of_pci_range range;
@@ -225,7 +226,10 @@ int of_pci_get_host_bridge_resources(struct device_node *dev,
225conversion_failed: 226conversion_failed:
226 kfree(res); 227 kfree(res);
227parse_failed: 228parse_failed:
229 list_for_each_entry(window, resources, list)
230 kfree(window->res);
228 pci_free_resource_list(resources); 231 pci_free_resource_list(resources);
232 kfree(bus_range);
229 return err; 233 return err;
230} 234}
231EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources); 235EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources);