diff options
author | Muhammad Falak R Wani <falakreyaz@gmail.com> | 2016-07-21 02:53:18 +0200 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2016-07-21 02:57:30 +0200 |
commit | 0097ff3d5dad1f76c5e1099d849d52509500708c (patch) | |
tree | 8b0e6655a0bd9b907a8785d683b1f556af8907b3 | |
parent | Input: pegasus_notetaker - set device mode in reset_resume() if in use (diff) | |
download | linux-0097ff3d5dad1f76c5e1099d849d52509500708c.tar.xz linux-0097ff3d5dad1f76c5e1099d849d52509500708c.zip |
Input: tty/vt/keyboard - use memdup_user()
Use memdup_user to duplicate a memory region from user-space to
kernel-space, instead of open coding using kmalloc & copy_from_user.
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/tty/vt/keyboard.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index f973bfce5d08..698ea43fd01e 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c @@ -1745,16 +1745,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, + ct * sizeof(struct kbdiacruc)); + if (IS_ERR(buf)) + return PTR_ERR(buf); } spin_lock_irqsave(&kbd_event_lock, flags); if (ct) |