From: Amitoj Kaur Chawla Date: Mon, 15 Feb 2016 19:25:25 +0000 (+0530) Subject: staging: rdma: hfi1: Replace kmalloc and memcpy with kmemdup X-Git-Tag: v5.15~14007^2~688 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94b397cd253396c601d871f250cd93362618bdf6;p=platform%2Fkernel%2Flinux-starfive.git staging: rdma: hfi1: Replace kmalloc and memcpy with kmemdup Replace kmalloc and memcpy with kmemdup. Found using Coccinelle. The semantic patch used to make this change can be found here: scripts/coccinelle/api/memdup.cocci Signed-off-by: Amitoj Kaur Chawla Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/rdma/hfi1/efivar.c b/drivers/staging/rdma/hfi1/efivar.c index e569f9f..47dfe25 100644 --- a/drivers/staging/rdma/hfi1/efivar.c +++ b/drivers/staging/rdma/hfi1/efivar.c @@ -127,13 +127,12 @@ static int read_efi_var(const char *name, unsigned long *size, * temporary buffer. Now allocate a correctly sized * buffer. */ - data = kmalloc(temp_size, GFP_KERNEL); + data = kmemdup(temp_buffer, temp_size, GFP_KERNEL); if (!data) { ret = -ENOMEM; goto fail; } - memcpy(data, temp_buffer, temp_size); *size = temp_size; *return_data = data;