From: Samuel Zou <zou_wei@huawei.com>
To: Zhou Wang <wangzhou1@hisilicon.com>,
<herbert@gondor.apana.org.au>, <davem@davemloft.net>
Cc: <linux-crypto@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next] crypto: hisilicon -: switch to memdup_user_nul()
Date: Wed, 12 May 2021 15:04:07 +0800 [thread overview]
Message-ID: <04aa944f-c07c-1263-a17d-ac647725e2b9@huawei.com> (raw)
In-Reply-To: <c3bfff60-5e78-c0b0-797b-499c70da0ff2@hisilicon.com>
Hi,
Sorry for the mistake, I will send v2 soon.
On 2021/5/11 15:07, Zhou Wang wrote:
> On 2021/5/11 14:37, Zou Wei wrote:
>> Use memdup_user_nul() helper instead of open-coding to
>> simplify the code.
>>
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Zou Wei <zou_wei@huawei.com>
>> ---
>> drivers/crypto/hisilicon/qm.c | 11 ++---------
>> 1 file changed, 2 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
>> index ce439a0..83a5d30 100644
>> --- a/drivers/crypto/hisilicon/qm.c
>> +++ b/drivers/crypto/hisilicon/qm.c
>> @@ -1570,17 +1570,10 @@ static ssize_t qm_cmd_write(struct file *filp, const char __user *buffer,
>> if (count > QM_DBG_WRITE_LEN)
>> return -ENOSPC;
>>
>> - cmd_buf = kzalloc(count + 1, GFP_KERNEL);
>> - if (!cmd_buf)
>> + cmd_buf = memdup_user_nul(buffer, count);
>> + if (IS_ERR(cmd_buf))
>> return -ENOMEM;
>>
>> - if (copy_from_user(cmd_buf, buffer, count)) {
>> - kfree(cmd_buf);
>> - return -EFAULT;
>> - }
>> -
>> - cmd_buf[count] = '\0';
>> -
>> cmd_buf_tmp = strchr(cmd_buf, '\n');
>> if (cmd_buf_tmp) {
>> *cmd_buf_tmp = '\0';
>>
>
> It is fine to me, thanks!
>
> BTW, normally we use crypto: hisilicon - switch to memdup_user_nul() as the subject line,
> just like other patches :)
>
> .
>
prev parent reply other threads:[~2021-05-12 7:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-11 6:37 Zou Wei
2021-05-11 7:07 ` Zhou Wang
2021-05-12 7:04 ` Samuel Zou [this message]
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=04aa944f-c07c-1263-a17d-ac647725e2b9@huawei.com \
--to=zou_wei@huawei.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wangzhou1@hisilicon.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
all inboxes | Powered by JetHome®