[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <3a3680030905030900x672af596mc2ebc3c38f119c92@mail.gmail.com>
Date: Mon, 4 May 2009 00:00:56 +0800
From: Li Hong <lihong.hi@...il.com>
To: oliver@...kum.name, linux-usb@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] usb: use memdup_user()
Replace a combination call of kmalloc() and copy_from_user() with memdup_user().
Signed-off-by: Li Hong <lihong.hi@...il.com>
---
drivers/usb/class/cdc-wdm.c | 15 ++++-----------
1 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 0fe4345..326ecf3 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -324,18 +324,11 @@ static ssize_t wdm_write
goto out;
}
- desc->outbuf = buf = kmalloc(count, GFP_KERNEL);
- if (!buf) {
- rv = -ENOMEM;
+ desc->outbuf = buf = memdup_user(buffer, count);
+ if (IS_ERR(buf)) {
+ rv = PTR_ERR(buf);
goto out;
- }
-
- r = copy_from_user(buf, buffer, count);
- if (r > 0) {
- kfree(buf);
- rv = -EFAULT;
- goto out;
- }
+ }
req = desc->orq;
usb_fill_control_urb(
--
1.6.2.GIT
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists