Commit 64b9533e authored by Geliang Tang's avatar Geliang Tang Committed by Greg Kroah-Hartman

usb: cdc-wdm: use memdup_user

Use memdup_user() helper instead of open-coding to simplify the code.
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Acked-by: default avatarOliver Neukum <oneukum@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2ea659a9
......@@ -361,17 +361,9 @@ static ssize_t wdm_write
if (we < 0)
return usb_translate_errors(we);
buf = kmalloc(count, GFP_KERNEL);
if (!buf) {
rv = -ENOMEM;
goto outnl;
}
r = copy_from_user(buf, buffer, count);
if (r > 0) {
rv = -EFAULT;
goto out_free_mem;
}
buf = memdup_user(buffer, count);
if (IS_ERR(buf))
return PTR_ERR(buf);
/* concurrent writes and disconnect */
r = mutex_lock_interruptible(&desc->wlock);
......@@ -441,8 +433,7 @@ static ssize_t wdm_write
usb_autopm_put_interface(desc->intf);
mutex_unlock(&desc->wlock);
outnl:
return rv < 0 ? rv : count;
return count;
out_free_mem_pm:
usb_autopm_put_interface(desc->intf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment