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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <X8oLf3cLChRjWqPp@localhost>
Date:   Fri, 4 Dec 2020 11:12:15 +0100
From:   Johan Hovold <johan@...nel.org>
To:     Himadri Pandya <himadrispandya@...il.com>
Cc:     johan@...nel.org, gregkh@...uxfoundation.org,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-kernel-mentees@...ts.linuxfoundation.org
Subject: Re: [PATCH 10/15] usb: serial: io_ti: use usb_control_msg_recv() and
 usb_control_msg_send()

On Wed, Nov 04, 2020 at 12:16:58PM +0530, Himadri Pandya wrote:
> The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps
> usb_control_msg() with proper error check. Hence use the wrappers
> instead of calling usb_control_msg() directly
> 
> Signed-off-by: Himadri Pandya <himadrispandya@...il.com>
> ---
>  drivers/usb/serial/io_ti.c | 28 ++++++++++------------------
>  1 file changed, 10 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
> index c327d4cf7928..ab2370b80b3c 100644
> --- a/drivers/usb/serial/io_ti.c
> +++ b/drivers/usb/serial/io_ti.c
> @@ -260,16 +260,12 @@ static int ti_vread_sync(struct usb_device *dev, __u8 request,
>  {
>  	int status;
>  
> -	status = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,
> -			(USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN),
> -			value, index, data, size, 1000);
> -	if (status < 0)
> +	status = usb_control_msg_recv(dev, 0, request, USB_TYPE_VENDOR |
> +				      USB_RECIP_DEVICE | USB_DIR_IN, value,
> +				      index, data, size, 1000, GFP_KERNEL);
> +	if (status)
>  		return status;
> -	if (status != size) {
> -		dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n",
> -			__func__, size, status);
> -		return -ECOMM;
> -	}
> +
>  	return 0;
>  }
>  
> @@ -278,16 +274,12 @@ static int ti_vsend_sync(struct usb_device *dev, u8 request, u16 value,
>  {
>  	int status;
>  
> -	status = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request,
> -			(USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT),
> -			value, index, data, size, timeout);
> -	if (status < 0)
> +	status = usb_control_msg_send(dev, 0, request, USB_TYPE_VENDOR |
> +				      USB_RECIP_DEVICE | USB_DIR_OUT, value,
> +				      index, data, size, timeout, GFP_KERNEL);
> +	if (status)
>  		return status;
> -	if (status != size) {
> -		dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n",
> -			__func__, size, status);
> -		return -ECOMM;
> -	}
> +
>  	return 0;
>  }

These helper are only used with DMA-able buffers so this change
introduces an additional redundant allocation and memcpy for every call
for no real gain.

Please drop this one as well.

Johan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ