lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170515101433.GG3657@localhost>
Date:   Mon, 15 May 2017 12:14:33 +0200
From:   Johan Hovold <johan@...nel.org>
To:     Geliang Tang <geliangtang@...il.com>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Johan Hovold <johan@...nel.org>,
        Wolfram Sang <wsa-dev@...g-engineering.com>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] USB: iowarrior: use memdup_user

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@...il.com>

Looks good to me:

Reviewed-by: Johan Hovold <johan@...nel.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);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ