mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 17:50:54 +07:00
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: cbe4097f8a
("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>
This commit is contained in:
parent
97bf6af1f9
commit
d2be00c0fb
@ -140,6 +140,7 @@ int of_pci_get_host_bridge_resources(struct device_node *dev,
|
|||||||
unsigned char busno, unsigned char bus_max,
|
unsigned char busno, unsigned char bus_max,
|
||||||
struct list_head *resources, resource_size_t *io_base)
|
struct list_head *resources, resource_size_t *io_base)
|
||||||
{
|
{
|
||||||
|
struct pci_host_bridge_window *window;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
struct resource *bus_range;
|
struct resource *bus_range;
|
||||||
struct of_pci_range range;
|
struct of_pci_range range;
|
||||||
@ -225,7 +226,10 @@ int of_pci_get_host_bridge_resources(struct device_node *dev,
|
|||||||
conversion_failed:
|
conversion_failed:
|
||||||
kfree(res);
|
kfree(res);
|
||||||
parse_failed:
|
parse_failed:
|
||||||
|
list_for_each_entry(window, resources, list)
|
||||||
|
kfree(window->res);
|
||||||
pci_free_resource_list(resources);
|
pci_free_resource_list(resources);
|
||||||
|
kfree(bus_range);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources);
|
EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources);
|
||||||
|
Loading…
Reference in New Issue
Block a user