* [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul()
@ 2021-04-01 3:17 Yang Yingliang
2021-04-01 5:59 ` Greg KH
2021-04-01 7:43 ` Dan Carpenter
0 siblings, 2 replies; 7+ messages in thread
From: Yang Yingliang @ 2021-04-01 3:17 UTC (permalink / raw)
To: linux-kernel, linux-staging; +Cc: johan, elder, gregkh
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);;
ret = op->execute(gcam, kbuf, len);
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul()
2021-04-01 3:17 [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul() Yang Yingliang
@ 2021-04-01 5:59 ` Greg KH
2021-04-01 9:10 ` Yang Yingliang
2021-04-01 7:43 ` Dan Carpenter
1 sibling, 1 reply; 7+ messages in thread
From: Greg KH @ 2021-04-01 5:59 UTC (permalink / raw)
To: Yang Yingliang; +Cc: linux-kernel, linux-staging, johan, elder
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(-)
What changed from v1?
Always put that below the --- line like the documentation asks you to.
Please fix up and send a v3.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul()
2021-04-01 3:17 [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul() Yang Yingliang
2021-04-01 5:59 ` Greg KH
@ 2021-04-01 7:43 ` Dan Carpenter
2021-04-01 7:47 ` Dan Carpenter
2021-04-01 9:11 ` Yang Yingliang
1 sibling, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2021-04-01 7:43 UTC (permalink / raw)
To: Yang Yingliang; +Cc: linux-kernel, linux-staging, johan, elder, gregkh
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.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul()
2021-04-01 7:43 ` Dan Carpenter
@ 2021-04-01 7:47 ` Dan Carpenter
2021-04-01 9:20 ` Yang Yingliang
2021-04-01 9:11 ` Yang Yingliang
1 sibling, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2021-04-01 7:47 UTC (permalink / raw)
To: Yang Yingliang; +Cc: linux-kernel, linux-staging, johan, elder, gregkh
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:'
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul()
2021-04-01 5:59 ` Greg KH
@ 2021-04-01 9:10 ` Yang Yingliang
0 siblings, 0 replies; 7+ messages in thread
From: Yang Yingliang @ 2021-04-01 9:10 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel, linux-staging, johan, elder
On 2021/4/1 13:59, Greg KH 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(-)
> What changed from v1?
>
> Always put that below the --- line like the documentation asks you to.
> Please fix up and send a v3.
OK, I will add the changelog and send a v3 later
Thanks,
Yang
>
> thanks,
>
> greg k-h
> .
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul()
2021-04-01 7:43 ` Dan Carpenter
2021-04-01 7:47 ` Dan Carpenter
@ 2021-04-01 9:11 ` Yang Yingliang
1 sibling, 0 replies; 7+ messages in thread
From: Yang Yingliang @ 2021-04-01 9:11 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-kernel, linux-staging, johan, elder, gregkh
On 2021/4/1 15:43, 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.
I will remove it, and send a v3 later.
Thanks,
Yang
>
> regards,
> dan carpenter
>
> .
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul()
2021-04-01 7:47 ` Dan Carpenter
@ 2021-04-01 9:20 ` Yang Yingliang
0 siblings, 0 replies; 7+ messages in thread
From: Yang Yingliang @ 2021-04-01 9:20 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-kernel, linux-staging, johan, elder, gregkh
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
>
> .
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-04-01 9:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 3:17 [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul() 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
2021-04-01 9:11 ` Yang Yingliang
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).