Commit 1051937d authored by Saurabh Sengar's avatar Saurabh Sengar Committed by Greg Kroah-Hartman

tty/vt/keyboard: use memdup_user to simplify code

use memdup_user rather than duplicating implementation.
found by coccinelle
Signed-off-by: default avatarSaurabh Sengar <saurabh.truth@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fc7f47bf
...@@ -1706,16 +1706,12 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm) ...@@ -1706,16 +1706,12 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
return -EINVAL; return -EINVAL;
if (ct) { if (ct) {
dia = kmalloc(sizeof(struct kbdiacr) * ct,
GFP_KERNEL);
if (!dia)
return -ENOMEM;
if (copy_from_user(dia, a->kbdiacr, dia = memdup_user(a->kbdiacr,
sizeof(struct kbdiacr) * ct)) { sizeof(struct kbdiacr) * ct);
kfree(dia); if (IS_ERR(dia))
return -EFAULT; return PTR_ERR(dia);
}
} }
spin_lock_irqsave(&kbd_event_lock, flags); spin_lock_irqsave(&kbd_event_lock, flags);
......
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