summaryrefslogtreecommitdiff
path: root/drivers/scsi/aacraid
diff options
context:
space:
mode:
authorZou Wei <zou_wei@huawei.com>2020-04-26 10:42:44 +0800
committerMartin K. Petersen <martin.petersen@oracle.com>2020-05-11 22:13:18 -0400
commit8d925b1f00e6894e4c601cb1d395dab3bd66c374 (patch)
treeb1469cb10aba8e0f781e07d08801ee0dba9b4883 /drivers/scsi/aacraid
parent29022b61307f1aab5564ef65dc268ab7f55b699c (diff)
scsi: aacraid: Use memdup_user() as a cleanup
Fix coccicheck warning which recommends to use memdup_user(). This patch fixes the following coccicheck warning: drivers/scsi/aacraid/commctrl.c:516:15-22: WARNING opportunity for memdup_user Link: https://lore.kernel.org/r/1587868964-75969-1-git-send-email-zou_wei@huawei.com Fixes: 4645df1035b3 ("[PATCH] aacraid: swapped kmalloc args.") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Zou Wei <zou_wei@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/aacraid')
-rw-r--r--drivers/scsi/aacraid/commctrl.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index ffe41bc111fc..102658bdc15a 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -513,15 +513,9 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
goto cleanup;
}
- user_srbcmd = kmalloc(fibsize, GFP_KERNEL);
- if (!user_srbcmd) {
- dprintk((KERN_DEBUG"aacraid: Could not make a copy of the srb\n"));
- rcode = -ENOMEM;
- goto cleanup;
- }
- if(copy_from_user(user_srbcmd, user_srb,fibsize)){
- dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n"));
- rcode = -EFAULT;
+ user_srbcmd = memdup_user(user_srb, fibsize);
+ if (IS_ERR(user_srbcmd)) {
+ rcode = PTR_ERR(user_srbcmd);
goto cleanup;
}