Replace a combination call of kmalloc() and copy_from_user() with memdup_user(). Signed-off-by: Li Hong <lihong.hi@xxxxxxxxx> --- 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-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html