ACPI / memhotplug: free memory device if acpi_memory_enable_device() failed
authorWen Congyang <wency@cn.fujitsu.com>
Fri, 16 Nov 2012 01:08:16 +0000 (02:08 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 16 Nov 2012 01:08:16 +0000 (02:08 +0100)
If acpi_memory_enable_device() fails, acpi_memory_enable_device() will
return a non-zero value, which means we fail to bind the memory device to
this driver.  So we should free memory device before
acpi_memory_device_add() returns.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/acpi_memhotplug.c

index c5e7b6d08ef317584b630baab614c757382e4284..e52ad5d3792dc195be298a850bdd8751c2596472 100644 (file)
@@ -421,9 +421,11 @@ static int acpi_memory_device_add(struct acpi_device *device)
        if (!acpi_memory_check_device(mem_device)) {
                /* call add_memory func */
                result = acpi_memory_enable_device(mem_device);
-               if (result)
+               if (result) {
                        printk(KERN_ERR PREFIX
                                "Error in acpi_memory_enable_device\n");
+                       acpi_memory_device_free(mem_device);
+               }
        }
        return result;
 }