mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-staging@lists.linux.dev>,
	<johan@kernel.org>, <elder@kernel.org>,
	<gregkh@linuxfoundation.org>
Subject: Re: [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul()
Date: Thu, 1 Apr 2021 17:20:07 +0800	[thread overview]
Message-ID: <b3a9b8ad-30b8-1716-1252-a6796b2c837a@huawei.com> (raw)
In-Reply-To: <20210401074719.GP2065@kadam>


On 2021/4/1 15:47, Dan Carpenter wrote:
> On Thu, Apr 01, 2021 at 10:43:32AM +0300, Dan Carpenter wrote:
>> On Thu, Apr 01, 2021 at 11:17:52AM +0800, Yang Yingliang wrote:
>>> Use memdup_user_nul() helper instead of open-coding to
>>> simplify the code.
>>>
>>> Reported-by: Hulk Robot <hulkci@huawei.com>
>>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>>> ---
>>>   drivers/staging/greybus/camera.c | 13 +++----------
>>>   1 file changed, 3 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c
>>> index b570e13394ac..2ecdc1bc5092 100644
>>> --- a/drivers/staging/greybus/camera.c
>>> +++ b/drivers/staging/greybus/camera.c
>>> @@ -1120,16 +1120,9 @@ static ssize_t gb_camera_debugfs_write(struct file *file,
>>>   	if (len > 1024)
>>>   		return -EINVAL;
>>>   
>>> -	kbuf = kmalloc(len + 1, GFP_KERNEL);
>>> -	if (!kbuf)
>>> -		return -ENOMEM;
>>> -
>>> -	if (copy_from_user(kbuf, buf, len)) {
>>> -		ret = -EFAULT;
>>> -		goto done;
>>> -	}
>>> -
>>> -	kbuf[len] = '\0';
>>> +	kbuf = memdup_user_nul(buf, len);
>>> +	if (IS_ERR(kbuf))
>>> +		return PTR_ERR(kbuf);;
>>                                      ^^
>> There is an extra semi-colon here.  Checkpatch actually catches this
>> sort of typo.
> So when someone makes a typo like this, my response is:
>
> 1) Let's add this to checkpatch (turns out it was already done)
> 2) Let's grep the kernel and fix the other instances.  The command would
> be something like: git grep ';;$' | grep '\.c:'
I search it in kernel and find some other instances like this, I can 
send some
patches to fix these.

Thanks,
Yang
>
> regards,
> dan carpenter
>
> .

  reply	other threads:[~2021-04-01  9:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01  3:17 Yang Yingliang
2021-04-01  5:59 ` Greg KH
2021-04-01  9:10   ` Yang Yingliang
2021-04-01  7:43 ` Dan Carpenter
2021-04-01  7:47   ` Dan Carpenter
2021-04-01  9:20     ` Yang Yingliang [this message]
2021-04-01  9:11   ` Yang Yingliang

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=b3a9b8ad-30b8-1716-1252-a6796b2c837a@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=dan.carpenter@oracle.com \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /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®