lkml.org 
[lkml]   [2009]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH] usb: use memdup_user()
    From
    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

    \
     
     \ /
      Last update: 2009-05-03 18:03    [W:0.019 / U:60.912 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site