diff options
author | Saurabh Sengar <saurabh.truth@gmail.com> | 2015-10-28 02:26:44 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-02-07 02:27:46 -0500 |
commit | 1051937d465665e3360ea7d9a3d2adfd86f47dd4 (patch) | |
tree | 6d8b13803702db52f2e0ba74e3e83523e94ab424 /drivers/tty/vt | |
parent | fc7f47bf1d0a45304809c42405f82eecfc04fd29 (diff) |
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>
Diffstat (limited to 'drivers/tty/vt')
-rw-r--r-- | drivers/tty/vt/keyboard.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index 6f0336fff501..f973bfce5d08 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c | |||
@@ -1706,16 +1706,12 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm) | |||
1706 | return -EINVAL; | 1706 | return -EINVAL; |
1707 | 1707 | ||
1708 | if (ct) { | 1708 | if (ct) { |
1709 | dia = kmalloc(sizeof(struct kbdiacr) * ct, | ||
1710 | GFP_KERNEL); | ||
1711 | if (!dia) | ||
1712 | return -ENOMEM; | ||
1713 | 1709 | ||
1714 | if (copy_from_user(dia, a->kbdiacr, | 1710 | dia = memdup_user(a->kbdiacr, |
1715 | sizeof(struct kbdiacr) * ct)) { | 1711 | sizeof(struct kbdiacr) * ct); |
1716 | kfree(dia); | 1712 | if (IS_ERR(dia)) |
1717 | return -EFAULT; | 1713 | return PTR_ERR(dia); |
1718 | } | 1714 | |
1719 | } | 1715 | } |
1720 | 1716 | ||
1721 | spin_lock_irqsave(&kbd_event_lock, flags); | 1717 | spin_lock_irqsave(&kbd_event_lock, flags); |