===================================================================
@@ -634,17 +634,19 @@ int pci_ext_cfg_avail(struct pci_dev *de
return 0;
}
+static void release_pci_sysdata(struct pci_host_bridge *bridge)
+{
+ struct pci_sysdata *sd = bridge->release_data;
+
+ kfree(sd);
+}
+
struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node)
{
LIST_HEAD(resources);
struct pci_bus *bus = NULL;
struct pci_sysdata *sd;
- /*
- * Allocate per-root-bus (not per bus) arch-specific data.
- * TODO: leak; this memory is never freed.
- * It's arguable whether it's worth the trouble to care.
- */
sd = kzalloc(sizeof(*sd), GFP_KERNEL);
if (!sd) {
printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busno);
@@ -654,7 +656,10 @@ struct pci_bus * __devinit pci_scan_bus_
x86_pci_root_bus_resources(busno, &resources);
printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busno);
bus = pci_scan_root_bus(NULL, busno, ops, sd, &resources);
- if (!bus) {
+ if (bus)
+ pci_set_host_bridge_release(to_pci_host_bridge(bus->bridge),
+ release_pci_sysdata, sd);
+ else {
pci_free_resource_list(&resources);
kfree(sd);
}