Commit 0097ff3d authored by Muhammad Falak R Wani's avatar Muhammad Falak R Wani Committed by Dmitry Torokhov

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: default avatarMuhammad Falak R Wani <falakreyaz@gmail.com>
Reviewed-by: default avatarSamuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent c1d7b7c1
...@@ -1745,16 +1745,10 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm) ...@@ -1745,16 +1745,10 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
return -EINVAL; return -EINVAL;
if (ct) { if (ct) {
buf = kmalloc(ct * sizeof(struct kbdiacruc), buf = memdup_user(a->kbdiacruc,
GFP_KERNEL); ct * sizeof(struct kbdiacruc));
if (buf == NULL) if (IS_ERR(buf))
return -ENOMEM; return PTR_ERR(buf);
if (copy_from_user(buf, a->kbdiacruc,
ct * sizeof(struct kbdiacruc))) {
kfree(buf);
return -EFAULT;
}
} }
spin_lock_irqsave(&kbd_event_lock, flags); spin_lock_irqsave(&kbd_event_lock, flags);
if (ct) if (ct)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment