From: Harish Chegondi Date: Sat, 5 Mar 2016 16:49:34 +0000 (-0800) Subject: IB/hfi1: Replace kmalloc and memcpy with a kmemdup X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=2b8b34a948d063c4e803105ec0a3e8d27bd97c19;p=linux-beck.git IB/hfi1: Replace kmalloc and memcpy with a kmemdup This change was recommended by Coccinelle tool when I ran the command: -bash-4.2$ make coccicheck MODE=patch M=drivers/infiniband/hw/hfi1/ Reviewed-by: Jubin John Reviewed-by: Mike Marciniszyn Reviewed-by: Dennis Dalessandro Signed-off-by: Harish Chegondi Signed-off-by: Doug Ledford --- diff --git a/drivers/staging/rdma/hfi1/efivar.c b/drivers/staging/rdma/hfi1/efivar.c index 5fe39241b635..3f014f96f9e0 100644 --- a/drivers/staging/rdma/hfi1/efivar.c +++ b/drivers/staging/rdma/hfi1/efivar.c @@ -125,13 +125,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;