All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: use memdup_user()
@ 2009-05-03 16:00 Li Hong
  2009-05-03 16:28 ` Oliver Neukum
  2009-05-03 17:09 ` Oliver Neukum
  0 siblings, 2 replies; 17+ messages in thread
From: Li Hong @ 2009-05-03 16:00 UTC (permalink / raw)
  To: oliver, linux-usb; +Cc: linux-kernel

Replace a combination call of kmalloc() and copy_from_user() with memdup_user().

Signed-off-by: Li Hong <lihong.hi@gmail.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

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

end of thread, other threads:[~2009-05-06 18:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-03 16:00 [PATCH] usb: use memdup_user() Li Hong
2009-05-03 16:28 ` Oliver Neukum
2009-05-03 17:09 ` Oliver Neukum
2009-05-04  3:38   ` Li Hong
2009-05-04  6:54     ` Oliver Neukum
2009-05-04  7:02       ` David Brownell
2009-05-04  7:41         ` Pekka Enberg
2009-05-04 14:53           ` Greg KH
2009-05-04 15:13             ` Li Hong
2009-05-05  8:50             ` Oliver Neukum
2009-05-04 14:01         ` Oliver Neukum
2009-05-05  6:11           ` Andrew Morton
2009-05-05 10:44             ` Oliver Neukum
2009-05-05 17:22               ` Andrew Morton
2009-05-06 13:34                 ` Oliver Neukum
2009-05-06 18:31                   ` Andrew Morton
2009-05-06 18:44                     ` Oliver Neukum

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.