IB/hfi1: Replace kmalloc and memcpy with a kmemdup
authorHarish Chegondi <harish.chegondi@intel.com>
Sat, 5 Mar 2016 16:49:34 +0000 (08:49 -0800)
committerDoug Ledford <dledford@redhat.com>
Thu, 17 Mar 2016 19:55:12 +0000 (15:55 -0400)
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 <jubin.john@intel.com>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Harish Chegondi <harish.chegondi@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/staging/rdma/hfi1/efivar.c

index 5fe3924..3f014f9 100644 (file)
@@ -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;