efi, pstore: Cocci spatch "memdup.spatch"
authorThomas Meyer <thomas@m3y3r.de>
Sat, 1 Jun 2013 09:40:02 +0000 (11:40 +0200)
committerTony Luck <tony.luck@intel.com>
Mon, 3 Jun 2013 22:37:02 +0000 (15:37 -0700)
Change a kmalloc() + memcpy() pair for a single kmemdup() call.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
drivers/firmware/efi/efi-pstore.c

index 202d2c85ba2e79e2db866e78a03dffa240967f25..c692bb6621783b81a5d1cff34a77b2c9af301a9d 100644 (file)
@@ -79,10 +79,9 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
                           &entry->var.DataSize, entry->var.Data);
        size = entry->var.DataSize;
 
-       *cb_data->buf = kmalloc(size, GFP_KERNEL);
+       *cb_data->buf = kmemdup(entry->var.Data, size, GFP_KERNEL);
        if (*cb_data->buf == NULL)
                return -ENOMEM;
-       memcpy(*cb_data->buf, entry->var.Data, size);
        return size;
 }