staging: rdma: hfi1: Replace kmalloc and memcpy with kmemdup
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>
Mon, 15 Feb 2016 19:25:25 +0000 (00:55 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Feb 2016 22:54:05 +0000 (14:54 -0800)
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 <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rdma/hfi1/efivar.c

index e569f9f456c5b5f6c201aaa0b3cb52625e0539be..47dfe25847605ac2903d07f98f52bd227079534c 100644 (file)
@@ -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;