Skip to content

Commit

Permalink
x86/PCI: embed pci_sysdata into pci_root_info on ACPI path
Browse files Browse the repository at this point in the history
Embed the x86 struct pci_sysdata in the struct pci_root_info so it
will be automatically freed in the remove path.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
  • Loading branch information
Yinghai Lu authored and Bjorn Helgaas committed Apr 30, 2012
1 parent fe05725 commit 35cb05e
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions arch/x86/pci/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct pci_root_info {
unsigned int res_num;
struct resource *res;
int busnum;
struct pci_sysdata sd;
};

static bool pci_use_crs = true;
Expand Down Expand Up @@ -410,26 +411,16 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
if (node != -1 && !node_online(node))
node = -1;

/* 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) {
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
printk(KERN_WARNING "pci_bus %04x:%02x: "
"ignored (out of memory)\n", domain, busnum);
return NULL;
}

sd = &info->sd;
sd->domain = domain;
sd->node = node;
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
kfree(sd);
printk(KERN_WARNING "pci_bus %04x:%02x: "
"ignored (out of memory)\n", domain, busnum);
return NULL;
}
/*
* Maybe the desired pci bus has been already scanned. In such case
* it is unnecessary to scan the pci bus with the given domain,busnum.
Expand All @@ -442,7 +433,6 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
*/
memcpy(bus->sysdata, sd, sizeof(*sd));
kfree(info);
kfree(sd);
} else {
probe_pci_root_info(info, device, busnum, domain);

Expand Down Expand Up @@ -484,9 +474,6 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
}
}

if (!bus)
kfree(sd);

if (bus && node != -1) {
#ifdef CONFIG_ACPI_NUMA
if (pxm >= 0)
Expand Down

0 comments on commit 35cb05e

Please sign in to comment.