Commit 22e9f5a6 authored by Muhammad Falak R Wani's avatar Muhammad Falak R Wani Committed by Martin K. Petersen

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: default avatarMuhammad Falak R Wani <falakreyaz@gmail.com>
Reviewed-by: default avatarRaghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 014e8ba7
...@@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) ...@@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
} }
} else { } else {
struct user_sgmap* usg; struct user_sgmap* usg;
usg = kmalloc(actual_fibsize - sizeof(struct aac_srb) usg = kmemdup(upsg,
+ sizeof(struct sgmap), GFP_KERNEL); actual_fibsize - sizeof(struct aac_srb)
+ sizeof(struct sgmap), GFP_KERNEL);
if (!usg) { if (!usg) {
dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n")); dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n"));
rcode = -ENOMEM; rcode = -ENOMEM;
goto cleanup; goto cleanup;
} }
memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb)
+ sizeof(struct sgmap));
actual_fibsize = actual_fibsize64; actual_fibsize = actual_fibsize64;
for (i = 0; i < usg->count; i++) { for (i = 0; i < usg->count; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment