lkml.org 
[lkml]   [2021]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul()
From
Date

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
>
> .

\
 
 \ /
  Last update: 2021-04-01 11:21    [W:0.152 / U:1.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site