Skip to content

Commit

Permalink
tty/vt/keyboard: use memdup_user to simplify code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Saurabh Sengar authored and Greg Kroah-Hartman committed Feb 7, 2016
1 parent fc7f47b commit 1051937
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions drivers/tty/vt/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1051937

Please sign in to comment.