Skip to content

Commit

Permalink
efi, pstore: Cocci spatch "memdup.spatch"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Meyer authored and Tony Luck committed Jun 3, 2013
1 parent d683b96 commit 7741892
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/firmware/efi/efi-pstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 7741892

Please sign in to comment.