public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Geliang Tang <geliangtang@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Johan Hovold <johan@kernel.org>,
	Wolfram Sang <wsa-dev@sang-engineering.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: iowarrior: use memdup_user
Date: Mon, 15 May 2017 12:14:33 +0200	[thread overview]
Message-ID: <20170515101433.GG3657@localhost> (raw)
In-Reply-To: <22d5f8beb9d993abad615edadfbc23c14a0bdb8d.1494579009.git.geliangtang@gmail.com>

On Sat, May 13, 2017 at 11:16:00AM +0800, Geliang Tang wrote:
> Use memdup_user() helper instead of open-coding to simplify the code.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Looks good to me:

Reviewed-by: Johan Hovold <johan@kernel.org>

> ---
>  drivers/usb/misc/iowarrior.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
> index 7756953..816afad 100644
> --- a/drivers/usb/misc/iowarrior.c
> +++ b/drivers/usb/misc/iowarrior.c
> @@ -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);

      reply	other threads:[~2017-05-15 10:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-13  3:15 [PATCH] KEYS: use memdup_user Geliang Tang
2017-05-13  3:15 ` [PATCH] mmc: block: " Geliang Tang
2017-05-19  7:43   ` Ulf Hansson
2017-05-13  3:15 ` [PATCH] usb: gadget: f_fs: " Geliang Tang
2017-05-13  8:05   ` Dan Carpenter
2017-05-21  3:25     ` Al Viro
2017-05-14 11:33   ` Michal Nazarewicz
2017-05-13  3:16 ` [PATCH] USB: iowarrior: " Geliang Tang
2017-05-15 10:14   ` Johan Hovold [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170515101433.GG3657@localhost \
    --to=johan@kernel.org \
    --cc=geliangtang@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=wsa-dev@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox