From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: Zou Wei <zou_wei@huawei.com>
Cc: <aacraid@microsemi.com>, <jejb@linux.ibm.com>,
<martin.petersen@oracle.com>, <linux-scsi@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next] scsi: aacraid: Use memdup_user() as a cleanup
Date: Fri, 24 Apr 2020 18:23:26 -0400 [thread overview]
Message-ID: <yq1wo64bk0x.fsf@oracle.com> (raw)
In-Reply-To: <1587524232-118733-1-git-send-email-zou_wei@huawei.com> (Zou Wei's message of "Wed, 22 Apr 2020 10:57:12 +0800")
Zou,
> diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
> index ffe41bc..1ce1620 100644
> --- a/drivers/scsi/aacraid/commctrl.c
> +++ b/drivers/scsi/aacraid/commctrl.c
> @@ -513,17 +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;
> - goto cleanup;
> - }
> + user_srbcmd = memdup_user(user_srb, fibsize);
> + if (IS_ERR(user_srbcmd))
> + return PTR_ERR(user_srbcmd);
>
> flags = user_srbcmd->flags; /* from user in cpu order */
> switch (flags & (SRB_DataIn | SRB_DataOut)) {
This is not equivalent, is it? The original code does a goto cleanup;
whereas your patch returns on error.
--
Martin K. Petersen Oracle Linux Engineering
next prev parent reply other threads:[~2020-04-24 22:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-22 2:57 [PATCH -next] scsi: aacraid: Use memdup_user() as a cleanup Zou Wei
2020-04-24 22:23 ` Martin K. Petersen [this message]
2020-04-26 2:32 ` Samuel Zou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yq1wo64bk0x.fsf@oracle.com \
--to=martin.petersen@oracle.com \
--cc=aacraid@microsemi.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=zou_wei@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox