Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca2ef0d5 authored by Geliang Tang's avatar Geliang Tang Committed by Greg Kroah-Hartman
Browse files

USB: iowarrior: use memdup_user



Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Reviewed-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2aa3add0
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -368,14 +368,9 @@ static ssize_t iowarrior_write(struct file *file,
	case USB_DEVICE_ID_CODEMERCS_IOWPV2:
	case USB_DEVICE_ID_CODEMERCS_IOW40:
		/* IOW24 and IOW40 use a synchronous call */
		buf = kmalloc(count, GFP_KERNEL);
		if (!buf) {
			retval = -ENOMEM;
			goto exit;
		}
		if (copy_from_user(buf, user_buffer, count)) {
			retval = -EFAULT;
			kfree(buf);
		buf = memdup_user(user_buffer, count);
		if (IS_ERR(buf)) {
			retval = PTR_ERR(buf);
			goto exit;
		}
		retval = usb_set_report(dev->interface, 2, 0, buf, count);