Commit 2b1df724 authored by Sebastian Ott's avatar Sebastian Ott Committed by Martin Schwidefsky

s390/pci: free resources after failed bus allocation

Free bus resources when the allocation/registration of the bus failed.
Reviewed-by: default avatarGerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 64776820
...@@ -632,7 +632,7 @@ static void zpci_cleanup_bus_resources(struct zpci_dev *zdev) ...@@ -632,7 +632,7 @@ static void zpci_cleanup_bus_resources(struct zpci_dev *zdev)
int i; int i;
for (i = 0; i < PCI_BAR_COUNT; i++) { for (i = 0; i < PCI_BAR_COUNT; i++) {
if (!zdev->bars[i].size) if (!zdev->bars[i].size || !zdev->bars[i].res)
continue; continue;
zpci_free_iomap(zdev, zdev->bars[i].map_idx); zpci_free_iomap(zdev, zdev->bars[i].map_idx);
...@@ -772,17 +772,22 @@ static int zpci_scan_bus(struct zpci_dev *zdev) ...@@ -772,17 +772,22 @@ static int zpci_scan_bus(struct zpci_dev *zdev)
ret = zpci_setup_bus_resources(zdev, &resources); ret = zpci_setup_bus_resources(zdev, &resources);
if (ret) if (ret)
return ret; goto error;
zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops, zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
zdev, &resources); zdev, &resources);
if (!zdev->bus) { if (!zdev->bus) {
zpci_cleanup_bus_resources(zdev); ret = -EIO;
return -EIO; goto error;
} }
zdev->bus->max_bus_speed = zdev->max_bus_speed; zdev->bus->max_bus_speed = zdev->max_bus_speed;
pci_bus_add_devices(zdev->bus); pci_bus_add_devices(zdev->bus);
return 0; return 0;
error:
zpci_cleanup_bus_resources(zdev);
pci_free_resource_list(&resources);
return ret;
} }
int zpci_enable_device(struct zpci_dev *zdev) int zpci_enable_device(struct zpci_dev *zdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment