* [PATCH -next v2] scsi: aacraid: Use memdup_user() as a cleanup
@ 2020-04-26 2:42 Zou Wei
2020-05-12 3:28 ` Martin K. Petersen
0 siblings, 1 reply; 2+ messages in thread
From: Zou Wei @ 2020-04-26 2:42 UTC (permalink / raw)
To: aacraid, jejb, martin.petersen; +Cc: linux-scsi, linux-kernel, Zou Wei
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
Fixes: 4645df1035b3 ("[PATCH] aacraid: swapped kmalloc args.")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
---
drivers/scsi/aacraid/commctrl.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index ffe41bc..102658b 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;
}
--
2.6.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next v2] scsi: aacraid: Use memdup_user() as a cleanup
2020-04-26 2:42 [PATCH -next v2] scsi: aacraid: Use memdup_user() as a cleanup Zou Wei
@ 2020-05-12 3:28 ` Martin K. Petersen
0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2020-05-12 3:28 UTC (permalink / raw)
To: Zou Wei, aacraid, jejb; +Cc: Martin K . Petersen, linux-kernel, linux-scsi
On Sun, 26 Apr 2020 10:42:44 +0800, Zou Wei wrote:
> 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
Applied to 5.8/scsi-queue, thanks!
[1/1] scsi: aacraid: Use memdup_user() as a cleanup
https://git.kernel.org/mkp/scsi/c/8d925b1f00e6
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-12 3:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-26 2:42 [PATCH -next v2] scsi: aacraid: Use memdup_user() as a cleanup Zou Wei
2020-05-12 3:28 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).