tty/vt/keyboard: use memdup_user to simplify code

use memdup_user rather than duplicating implementation.
found by coccinelle

Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Saurabh Sengar 2015-10-28 11:56:44 +05:30 committed by Greg Kroah-Hartman
parent fc7f47bf1d
commit 1051937d46
1 changed files with 5 additions and 9 deletions

View File

@ -1706,16 +1706,12 @@ 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);