aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2012-03-15 04:32:05 -0400
committerLen Brown <len.brown@intel.com>2012-03-30 03:30:34 -0400
commitc80f5b31f3c55a197f5323b93d1e3553429a427e (patch)
tree4cc2183ddf4ce79765bb6d02f3d6b9191f3bcbe5
parentc6436f5a395d346e9f4892d7aeed4c3f99261f0f (diff)
ACPI: processor_driver: add missing kfree
The function acpi_processor_add is stored in the ops.add field of a acpi_driver structure. This function is then called in acpi_bus_driver_init. On failure, this function clears the field device->driver_data, but does not free its contents. Thus the free has to be done by the add function. In acpi_processor_add, the corresponding value is pr. This value is currently freed on failure before storing it in device->driver_data, but not after. This free is added in the error handling code at the end of the function. The per_cpu variable processors is also cleared so that it does not refer to a dangling pointer. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Acked-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/processor_driver.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 8ae05ce18500..fce0066aa4a4 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -535,8 +535,8 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
535 return -ENOMEM; 535 return -ENOMEM;
536 536
537 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { 537 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
538 kfree(pr); 538 result = -ENOMEM;
539 return -ENOMEM; 539 goto err_free_pr;
540 } 540 }
541 541
542 pr->handle = device->handle; 542 pr->handle = device->handle;
@@ -576,7 +576,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
576 dev = get_cpu_device(pr->id); 576 dev = get_cpu_device(pr->id);
577 if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) { 577 if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) {
578 result = -EFAULT; 578 result = -EFAULT;
579 goto err_free_cpumask; 579 goto err_clear_processor;
580 } 580 }
581 581
582 /* 582 /*
@@ -594,9 +594,15 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
594 594
595err_remove_sysfs: 595err_remove_sysfs:
596 sysfs_remove_link(&device->dev.kobj, "sysdev"); 596 sysfs_remove_link(&device->dev.kobj, "sysdev");
597err_clear_processor:
598 /*
599 * processor_device_array is not cleared to allow checks for buggy BIOS
600 */
601 per_cpu(processors, pr->id) = NULL;
597err_free_cpumask: 602err_free_cpumask:
598 free_cpumask_var(pr->throttling.shared_cpu_map); 603 free_cpumask_var(pr->throttling.shared_cpu_map);
599 604err_free_pr:
605 kfree(pr);
600 return result; 606 return result;
601} 607}
602 608