@@ -157,16 +157,19 @@ static int __init cpcihp_generic_init(void)
bus = pci_find_bus(0, bridge_busnr);
if (!bus) {
err("Invalid bus number %d", bridge_busnr);
- return -EINVAL;
- }
- dev = pci_get_slot(bus, PCI_DEVFN(bridge_slot, 0));
- if(!dev || dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
- err("Invalid bridge device %s", bridge);
+ } else {
+ dev = pci_get_slot(bus, PCI_DEVFN(bridge_slot, 0));
+ if (!dev || dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
+ err("Invalid bridge device %s", bridge);
+ bus = NULL;
+ } else
+ bus = dev->subordinate;
pci_dev_put(dev);
- return -EINVAL;
}
- bus = dev->subordinate;
- pci_dev_put(dev);
+ if (!bus) {
+ status = -EINVAL;
+ goto init_find_bus_error;
+ }
memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
generic_hpc_ops.query_enum = query_enum;
@@ -175,7 +178,8 @@ static int __init cpcihp_generic_init(void)
status = cpci_hp_register_controller(&generic_hpc);
if(status != 0) {
err("Could not register cPCI hotplug controller");
- return -ENODEV;
+ status = -ENODEV;
+ goto init_find_bus_error;
}
dbg("registered controller");
@@ -193,10 +197,13 @@ static int __init cpcihp_generic_init(void)
}
dbg("started cpci hp system");
return 0;
+
init_start_error:
cpci_hp_unregister_bus(bus);
init_bus_register_error:
cpci_hp_unregister_controller(&generic_hpc);
+init_find_bus_error:
+ release_region(port, 1);
err("status = %d", status);
return status;