]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
aacraid: use kmemdup
authorMuhammad Falak R Wani <falakreyaz@gmail.com>
Thu, 19 May 2016 14:08:33 +0000 (19:38 +0530)
committerChuck Anderson <chuck.anderson@oracle.com>
Mon, 27 Feb 2017 06:21:07 +0000 (22:21 -0800)
Use kmemdup when some other buffer is immediately copied into allocated
region. It replaces call to allocation followed by memcpy, by a single
call to kmemdup.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 22e9f5a61666ed1145a09fbe49ac1a6f2ae7be8e)

Orabug: 25505509
Signed-off-by: Dhaval Giani <dhaval.giani@oracle.com>
drivers/scsi/aacraid/commctrl.c

index 4b3bb52b5108edbabf253d800a083c3f637c9380..b381b3718a98f5d484b1769fc4ef727f5fd4c0bd 100644 (file)
@@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
                        }
                } else {
                        struct user_sgmap* usg;
-                       usg = kmalloc(actual_fibsize - sizeof(struct aac_srb)
-                         + sizeof(struct sgmap), GFP_KERNEL);
+                       usg = kmemdup(upsg,
+                                     actual_fibsize - sizeof(struct aac_srb)
+                                     + sizeof(struct sgmap), GFP_KERNEL);
                        if (!usg) {
                                dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n"));
                                rcode = -ENOMEM;
                                goto cleanup;
                        }
-                       memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb)
-                         + sizeof(struct sgmap));
                        actual_fibsize = actual_fibsize64;
 
                        for (i = 0; i < usg->count; i++) {