Re: [PATCH v2] PCI/ACPI: Fix double free bug in pci_acpi_scan_root() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Wait, what?  We can't just delete pci_acpi_generic_release_info().
What's going to free all those things on the success path?  I
don't understand.

I had suggested you do something like this:

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 74ade4160314..ff5799b696d6 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -1012,20 +1012,20 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
 		 root->segment, busnum);
 
 	if (ops->init_info && ops->init_info(info))
-		goto out_release_info;
+		return NULL;
 	if (ops->prepare_resources)
 		ret = ops->prepare_resources(info);
 	else
 		ret = acpi_pci_probe_root_resources(info);
 	if (ret < 0)
-		goto out_release_info;
+		goto cleanup_init_info;
 
 	pci_acpi_root_add_resources(info);
 	pci_add_resource(&info->resources, &root->secondary);
 	bus = pci_create_root_bus(NULL, busnum, ops->pci_ops,
 				  sysdata, &info->resources);
 	if (!bus)
-		goto out_release_info;
+		goto cleanup_acpi_pci_probe_root_resources;
 
 	host_bridge = to_pci_host_bridge(bus->bridge);
 	if (!(root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
@@ -1053,8 +1053,10 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
 		dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d\n", node);
 	return bus;
 
+cleanup_acpi_pci_probe_root_resources:
+	free_something_with_probe();
 out_release_info:
-	__acpi_pci_root_release_info(info);
+	free_something_info();
 	return NULL;
 }
 

But you'd need to replace the dummy code with actual code and
change the callers etc.  And I haven't looked at the actual
code to verify it's a good idea.

regards,
dan carpenter





[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux