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: <20191016122656.3jpmes4rnz47u5wc@verge.net.au>
Date:   Wed, 16 Oct 2019 14:26:56 +0200
From:   Simon Horman <horms@...ge.net.au>
To:     "Ben Dooks (Codethink)" <ben.dooks@...ethink.co.uk>
Cc:     linux-kernel@...ts.codethink.co.uk,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>,
        Geert Uytterhoeven <geert+renesas@...der.be>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] usb: renesas_usbhs: fix __le16 warnings

On Tue, Oct 15, 2019 at 04:50:44PM +0100, Ben Dooks (Codethink) wrote:
> Fix the warnings generated by casting to/from __le16 without
> using the correct functions.
> 
> Fixes the following sparse warnings:
> 
> drivers/usb/renesas_usbhs/common.c:165:25: warning: incorrect type in assignment (different base types)
> drivers/usb/renesas_usbhs/common.c:165:25:    expected restricted __le16 [usertype] wValue
> drivers/usb/renesas_usbhs/common.c:165:25:    got unsigned short
> drivers/usb/renesas_usbhs/common.c:166:25: warning: incorrect type in assignment (different base types)
> drivers/usb/renesas_usbhs/common.c:166:25:    expected restricted __le16 [usertype] wIndex
> drivers/usb/renesas_usbhs/common.c:166:25:    got unsigned short
> drivers/usb/renesas_usbhs/common.c:167:25: warning: incorrect type in assignment (different base types)
> drivers/usb/renesas_usbhs/common.c:167:25:    expected restricted __le16 [usertype] wLength
> drivers/usb/renesas_usbhs/common.c:167:25:    got unsigned short
> drivers/usb/renesas_usbhs/common.c:173:39: warning: incorrect type in argument 3 (different base types)
> drivers/usb/renesas_usbhs/common.c:173:39:    expected unsigned short [usertype] data
> drivers/usb/renesas_usbhs/common.c:173:39:    got restricted __le16 [usertype] wValue
> drivers/usb/renesas_usbhs/common.c:174:39: warning: incorrect type in argument 3 (different base types)
> drivers/usb/renesas_usbhs/common.c:174:39:    expected unsigned short [usertype] data
> drivers/usb/renesas_usbhs/common.c:174:39:    got restricted __le16 [usertype] wIndex
> drivers/usb/renesas_usbhs/common.c:175:39: warning: incorrect type in argument 3 (different base types)
> drivers/usb/renesas_usbhs/common.c:175:39:    expected unsigned short [usertype] data
> 
> Note. I belive this to be correct, and should be a no-op on arm.
> 
> Signed-off-by: Ben Dooks <ben.dooks@...ethink.co.uk>
> ---
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>
> Cc: Simon Horman <horms+renesas@...ge.net.au>
> Cc: Geert Uytterhoeven <geert+renesas@...der.be>
> Cc: linux-usb@...r.kernel.org
> Cc: linux-kernel@...r.kernel.org
> ---
>  drivers/usb/renesas_usbhs/common.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
> index 4c3de777ef6c..a3c30b609433 100644
> --- a/drivers/usb/renesas_usbhs/common.c
> +++ b/drivers/usb/renesas_usbhs/common.c
> @@ -162,17 +162,17 @@ void usbhs_usbreq_get_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req)
>  	req->bRequest		= (val >> 8) & 0xFF;
>  	req->bRequestType	= (val >> 0) & 0xFF;
>  
> -	req->wValue	= usbhs_read(priv, USBVAL);
> -	req->wIndex	= usbhs_read(priv, USBINDX);
> -	req->wLength	= usbhs_read(priv, USBLENG);
> +	req->wValue	= cpu_to_le16(usbhs_read(priv, USBVAL));
> +	req->wIndex	= cpu_to_le16(usbhs_read(priv, USBINDX));
> +	req->wLength	= cpu_to_le16(usbhs_read(priv, USBLENG));

usbhs_read is backed by readl which performs
a le->cpu conversion. Rather than have a double conversion
perhaps it would be nicer to introduce usbhs_read_le.
Likewise for write.

>  }
>  
>  void usbhs_usbreq_set_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req)
>  {
>  	usbhs_write(priv, USBREQ,  (req->bRequest << 8) | req->bRequestType);
> -	usbhs_write(priv, USBVAL,  req->wValue);
> -	usbhs_write(priv, USBINDX, req->wIndex);
> -	usbhs_write(priv, USBLENG, req->wLength);
> +	usbhs_write(priv, USBVAL,  le16_to_cpu(req->wValue));
> +	usbhs_write(priv, USBINDX, le16_to_cpu(req->wIndex));
> +	usbhs_write(priv, USBLENG, le16_to_cpu(req->wLength));
>  
>  	usbhs_bset(priv, DCPCTR, SUREQ, SUREQ);
>  }
> -- 
> 2.23.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ