diff options
author | Muhammad Falak R Wani <falakreyaz@gmail.com> | 2016-05-19 10:08:33 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-07-12 23:16:31 -0400 |
commit | 22e9f5a61666ed1145a09fbe49ac1a6f2ae7be8e (patch) | |
tree | 69489981f43bbff21ce270e1356d6f199f9a6389 | |
parent | 014e8ba76ec3d6e75ab1811ea471e647a0b5dd92 (diff) |
aacraid: use kmemdup
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>
-rw-r--r-- | drivers/scsi/aacraid/commctrl.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 4b3bb52b5108..b381b3718a98 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c | |||
@@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) | |||
635 | } | 635 | } |
636 | } else { | 636 | } else { |
637 | struct user_sgmap* usg; | 637 | struct user_sgmap* usg; |
638 | usg = kmalloc(actual_fibsize - sizeof(struct aac_srb) | 638 | usg = kmemdup(upsg, |
639 | + sizeof(struct sgmap), GFP_KERNEL); | 639 | actual_fibsize - sizeof(struct aac_srb) |
640 | + sizeof(struct sgmap), GFP_KERNEL); | ||
640 | if (!usg) { | 641 | if (!usg) { |
641 | dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n")); | 642 | dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n")); |
642 | rcode = -ENOMEM; | 643 | rcode = -ENOMEM; |
643 | goto cleanup; | 644 | goto cleanup; |
644 | } | 645 | } |
645 | memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb) | ||
646 | + sizeof(struct sgmap)); | ||
647 | actual_fibsize = actual_fibsize64; | 646 | actual_fibsize = actual_fibsize64; |
648 | 647 | ||
649 | for (i = 0; i < usg->count; i++) { | 648 | for (i = 0; i < usg->count; i++) { |