]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
acpi_memhotplug.c: free memory device if acpi_memory_enable_device() failed
authorWen Congyang <wency@cn.fujitsu.com>
Fri, 28 Sep 2012 00:18:49 +0000 (10:18 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 11 Oct 2012 02:16:49 +0000 (13:16 +1100)
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>
Cc: Len Brown <lenb@kernel.org>
Cc: "Brown, Len" <len.brown@intel.com>
Cc: Yasuaki ISIMATU <isimatu.yasuaki@jp.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/acpi/acpi_memhotplug.c

index 62c2c74b5d9aa310eeb02175c4cba575c19eda5c..d97bb952a426ffd9fb9e115a917d5e54b6419ed3 100644 (file)
@@ -478,9 +478,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;
 }