Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1257699 > unrolled thread

[PATCH] tty/vt/keyboard: use memdup_user to simplify code

Started bySaurabh Sengar <saurabh.truth@gmail.com>
First post2015-10-28 07:30 +0100
Last post2015-10-28 07:30 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH] tty/vt/keyboard: use memdup_user to simplify code Saurabh Sengar <saurabh.truth@gmail.com> - 2015-10-28 07:30 +0100

#1257699 — [PATCH] tty/vt/keyboard: use memdup_user to simplify code

FromSaurabh Sengar <saurabh.truth@gmail.com>
Date2015-10-28 07:30 +0100
Subject[PATCH] tty/vt/keyboard: use memdup_user to simplify code
Message-ID<qospc-7q6-15@gated-at.bofh.it>
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web