Skip to contentSkip to conversation

IR/lirc: use memdup_user instead of copy_from_user

PATCH New Jarod Wilson 1 participant 1 message Jul 16, 2010 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IR/lirc: use memdup_user instead of copy_from_user

Inspired by 64047b94ede76e0c72ba8af98505e96d6a664519

---
 drivers/media/IR/ir-lirc-codec.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)
drivers/media/IR/ir-lirc-codec.c +3 -8
index afb1ada..ee1f2d4 100644
@@ -74,14 +74,9 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf,
 	if (count > LIRCBUF_SIZE || count % 2 == 0)
 		return -EINVAL;
 
-	txbuf = kzalloc(sizeof(int) * LIRCBUF_SIZE, GFP_KERNEL);
-	if (!txbuf)
-		return -ENOMEM;
-
-	if (copy_from_user(txbuf, buf, n)) {
-		ret = -EFAULT;
-		goto out;
-	}
+	txbuf = memdup_user(buf, n);
+	if (IS_ERR(txbuf))
+		return PTR_ERR(txbuf);
 
 	ir_dev = lirc->ir_dev;
 	if (!ir_dev) {
Signature · 5 lines
1.7.1.1

-- 
Jarod Wilson
[email protected]