All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty/vt/keyboard: use memdup_user to simplify code
@ 2015-10-28  6:26 Saurabh Sengar
  2015-11-19  7:18 ` Saurabh Sengar
  0 siblings, 1 reply; 2+ messages in thread
From: Saurabh Sengar @ 2015-10-28  6:26 UTC (permalink / raw)
  To: gregkh, jslaby, linux-kernel; +Cc: Saurabh Sengar

use memdup_user rather than duplicating implementation.
found by coccinelle

Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
---
 drivers/tty/vt/keyboard.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index 6f0336f..f973bfc 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)
 			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);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-19  7:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-28  6:26 [PATCH] tty/vt/keyboard: use memdup_user to simplify code Saurabh Sengar
2015-11-19  7:18 ` Saurabh Sengar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.