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: <f8785dc1-fa14-4e01-b89a-088cffdc350f@skidata.com>
Date:   Mon, 18 Mar 2019 16:46:31 +0100
From:   Richard Leitner <richard.leitner@...data.com>
To:     Marco Felsch <m.felsch@...gutronix.de>,
        "Gustavo A. R. Silva" <gustavo@...eddedor.com>
CC:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        <linux-usb@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] usb: usb251xb: Remove unnecessary comparison of unsigned
 integer with >= 0

Hi Marco, Hi Gustavo,
thanks for the fix, please feel free to add

	Reviewed-by: Richard Leitner <richard.leitner@...data.com>

On 18/03/2019 16:34, Marco Felsch wrote:
> Hi Silva,
> 
> On 19-03-18 09:50, Gustavo A. R. Silva wrote:
>> There is no need to compare *port* with >= 0 because such comparison
>> of an unsigned value is always true.
> 
> Absolutly.. It seems that it was an copy'n'paste failure. Thanks for
> fixing that.

A small note on further improvement from my side:

According the datasheet, when you set swap-dx-lanes to 0 (-> setting 
port to 0 -> setting bit 0 of PRTSP) "   the upstream port DP/DM is 
swapped".

IMHO this is not straight-forward, so maybe we want to additionally

	a) mention it somewhere in the documentation
	b) check on port >= 1
	c) something else?

Any opinions on that from your side? ... I'd prefer "a"...

regards;Richard.L

> 
> Regards,
> Marco
> 
>> Fix this by removing such comparison.
>>
>> Addresses-Coverity-ID: 1443949 ("Unsigned compared against 0")
>> Fixes: 02a50b875046 ("usb: usb251xb: add usb data lane port swap feature")
>> Signed-off-by: Gustavo A. R. Silva <gustavo@...eddedor.com>
>> ---
>>   drivers/usb/misc/usb251xb.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
>> index 4d72b7d1d383..2c8e2cad7e10 100644
>> --- a/drivers/usb/misc/usb251xb.c
>> +++ b/drivers/usb/misc/usb251xb.c
>> @@ -547,7 +547,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
>>   	 */
>>   	hub->port_swap = USB251XB_DEF_PORT_SWAP;
>>   	of_property_for_each_u32(np, "swap-dx-lanes", prop, p, port) {
>> -		if ((port >= 0) && (port <= data->port_cnt))
>> +		if (port <= data->port_cnt)
>>   			hub->port_swap |= BIT(port);
>>   	}
>>   
>> -- 
>> 2.21.0
>>
>>
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ