ACPI: replace kmalloc+memcpy with kmemdup
authorAndrei Epure <epure.andrei@gmail.com>
Mon, 11 Mar 2013 08:20:16 +0000 (08:20 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sun, 24 Mar 2013 22:31:33 +0000 (23:31 +0100)
Replace the combination of kmalloc() and memcpy() in acpi_run_osc()
with a single call to kmemdup().

[rjw: Changelog]
Signed-off-by: Andrei Epure <epure.andrei@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/bus.c

index 01708a1..292de3c 100644 (file)
@@ -288,13 +288,12 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
        }
 out_success:
        context->ret.length = out_obj->buffer.length;
-       context->ret.pointer = kmalloc(context->ret.length, GFP_KERNEL);
+       context->ret.pointer = kmemdup(out_obj->buffer.pointer,
+                                      context->ret.length, GFP_KERNEL);
        if (!context->ret.pointer) {
                status =  AE_NO_MEMORY;
                goto out_kfree;
        }
-       memcpy(context->ret.pointer, out_obj->buffer.pointer,
-               context->ret.length);
        status =  AE_OK;
 
 out_kfree: