* [PATCH] tty: vt: use memdup_user to reuse the code
@ 2015-12-19 18:45 Rahul Pathak
2015-12-21 20:04 ` Dmitry Torokhov
2016-02-07 7:31 ` Greg KH
0 siblings, 2 replies; 4+ messages in thread
From: Rahul Pathak @ 2015-12-19 18:45 UTC (permalink / raw)
To: gregkh, jslaby, samuel.thibault, pavel, dmitry.torokhov, linux-kernel
Fixing coccicheck warning which recommends to use memdup_user instead
to reimplement its code, using memdup_user simplifies the code
./drivers/tty/vt/keyboard.c:1709:9-16: WARNING opportunity for memdup_user
./drivers/tty/vt/keyboard.c:1752:9-16: WARNING opportunity for memdup_user
Signed-off-by: Rahul Pathak <rahulpathaklinux@gmail.com>
---
drivers/tty/vt/keyboard.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index 6f0336f..ec05360 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -1706,16 +1706,10 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
return -EINVAL;
if (ct) {
- dia = kmalloc(sizeof(struct kbdiacr) * ct,
- GFP_KERNEL);
- if (!dia)
- return -ENOMEM;
-
- if (copy_from_user(dia, a->kbdiacr,
- sizeof(struct kbdiacr) * ct)) {
- kfree(dia);
- return -EFAULT;
- }
+ dia = memdup_user(a->kbdiacr,
+ sizeof(struct kbdiacr) * ct);
+ if (IS_ERR(dia))
+ return PTR_ERR(dia);
}
spin_lock_irqsave(&kbd_event_lock, flags);
@@ -1749,16 +1743,10 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
return -EINVAL;
if (ct) {
- buf = kmalloc(ct * sizeof(struct kbdiacruc),
- GFP_KERNEL);
- if (buf == NULL)
- return -ENOMEM;
-
- if (copy_from_user(buf, a->kbdiacruc,
- ct * sizeof(struct kbdiacruc))) {
- kfree(buf);
- return -EFAULT;
- }
+ buf = memdup_user(a->kbdiacruc,
+ sizeof(struct kbdiacruc) * ct);
+ if (IS_ERR(buf))
+ return PTR_ERR(buf);
}
spin_lock_irqsave(&kbd_event_lock, flags);
if (ct)
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tty: vt: use memdup_user to reuse the code
2015-12-19 18:45 [PATCH] tty: vt: use memdup_user to reuse the code Rahul Pathak
@ 2015-12-21 20:04 ` Dmitry Torokhov
2016-02-07 7:31 ` Greg KH
1 sibling, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2015-12-21 20:04 UTC (permalink / raw)
To: Rahul Pathak; +Cc: gregkh, jslaby, samuel.thibault, pavel, linux-kernel
On Sun, Dec 20, 2015 at 12:15:33AM +0530, Rahul Pathak wrote:
> Fixing coccicheck warning which recommends to use memdup_user instead
> to reimplement its code, using memdup_user simplifies the code
>
> ./drivers/tty/vt/keyboard.c:1709:9-16: WARNING opportunity for memdup_user
> ./drivers/tty/vt/keyboard.c:1752:9-16: WARNING opportunity for memdup_user
>
> Signed-off-by: Rahul Pathak <rahulpathaklinux@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
(assuming Greg will pick it up, otherwise I can take it through my
tree).
Thanks.
> ---
> drivers/tty/vt/keyboard.c | 28 ++++++++--------------------
> 1 file changed, 8 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
> index 6f0336f..ec05360 100644
> --- a/drivers/tty/vt/keyboard.c
> +++ b/drivers/tty/vt/keyboard.c
> @@ -1706,16 +1706,10 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
> return -EINVAL;
>
> if (ct) {
> - dia = kmalloc(sizeof(struct kbdiacr) * ct,
> - GFP_KERNEL);
> - if (!dia)
> - return -ENOMEM;
> -
> - if (copy_from_user(dia, a->kbdiacr,
> - sizeof(struct kbdiacr) * ct)) {
> - kfree(dia);
> - return -EFAULT;
> - }
> + dia = memdup_user(a->kbdiacr,
> + sizeof(struct kbdiacr) * ct);
> + if (IS_ERR(dia))
> + return PTR_ERR(dia);
> }
>
> spin_lock_irqsave(&kbd_event_lock, flags);
> @@ -1749,16 +1743,10 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
> return -EINVAL;
>
> if (ct) {
> - buf = kmalloc(ct * sizeof(struct kbdiacruc),
> - GFP_KERNEL);
> - if (buf == NULL)
> - return -ENOMEM;
> -
> - if (copy_from_user(buf, a->kbdiacruc,
> - ct * sizeof(struct kbdiacruc))) {
> - kfree(buf);
> - return -EFAULT;
> - }
> + buf = memdup_user(a->kbdiacruc,
> + sizeof(struct kbdiacruc) * ct);
> + if (IS_ERR(buf))
> + return PTR_ERR(buf);
> }
> spin_lock_irqsave(&kbd_event_lock, flags);
> if (ct)
> --
> 2.1.4
>
--
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tty: vt: use memdup_user to reuse the code
2015-12-19 18:45 [PATCH] tty: vt: use memdup_user to reuse the code Rahul Pathak
2015-12-21 20:04 ` Dmitry Torokhov
@ 2016-02-07 7:31 ` Greg KH
2016-02-07 10:08 ` rahul pathak
1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2016-02-07 7:31 UTC (permalink / raw)
To: Rahul Pathak
Cc: jslaby, samuel.thibault, pavel, dmitry.torokhov, linux-kernel
On Sun, Dec 20, 2015 at 12:15:33AM +0530, Rahul Pathak wrote:
> Fixing coccicheck warning which recommends to use memdup_user instead
> to reimplement its code, using memdup_user simplifies the code
>
> ./drivers/tty/vt/keyboard.c:1709:9-16: WARNING opportunity for memdup_user
> ./drivers/tty/vt/keyboard.c:1752:9-16: WARNING opportunity for memdup_user
>
> Signed-off-by: Rahul Pathak <rahulpathaklinux@gmail.com>
> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/tty/vt/keyboard.c | 28 ++++++++--------------------
> 1 file changed, 8 insertions(+), 20 deletions(-)
Someone else sent half of this patch already, can you redo it against my
tty-testing branch of the tty.git tree and resend it?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tty: vt: use memdup_user to reuse the code
2016-02-07 7:31 ` Greg KH
@ 2016-02-07 10:08 ` rahul pathak
0 siblings, 0 replies; 4+ messages in thread
From: rahul pathak @ 2016-02-07 10:08 UTC (permalink / raw)
To: Greg KH; +Cc: jslaby, Samuel Thibault, pavel, Dmitry Torokhov, linux-kernel
Hello Greg,
Yes I will do this.
Thanks
Rahul
On Sun, Feb 7, 2016 at 1:01 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Sun, Dec 20, 2015 at 12:15:33AM +0530, Rahul Pathak wrote:
>> Fixing coccicheck warning which recommends to use memdup_user instead
>> to reimplement its code, using memdup_user simplifies the code
>>
>> ./drivers/tty/vt/keyboard.c:1709:9-16: WARNING opportunity for memdup_user
>> ./drivers/tty/vt/keyboard.c:1752:9-16: WARNING opportunity for memdup_user
>>
>> Signed-off-by: Rahul Pathak <rahulpathaklinux@gmail.com>
>> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> ---
>> drivers/tty/vt/keyboard.c | 28 ++++++++--------------------
>> 1 file changed, 8 insertions(+), 20 deletions(-)
>
> Someone else sent half of this patch already, can you redo it against my
> tty-testing branch of the tty.git tree and resend it?
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-07 10:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-19 18:45 [PATCH] tty: vt: use memdup_user to reuse the code Rahul Pathak
2015-12-21 20:04 ` Dmitry Torokhov
2016-02-07 7:31 ` Greg KH
2016-02-07 10:08 ` rahul pathak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.