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: <d37c85d8-3954-e7b7-e569-f18c2b062966@canonical.com>
Date:   Thu, 24 Aug 2017 09:54:03 +0100
From:   Colin Ian King <colin.king@...onical.com>
To:     Aviad Krawczyk <aviad.krawczyk@...wei.com>, netdev@...r.kernel.org
Cc:     kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][next] net: hinic: fix comparison of a uint16_t type with
 -1

On 24/08/17 09:48, Aviad Krawczyk wrote:
> On 8/23/2017 6:39 PM, Colin King wrote:
>> From: Colin Ian King <colin.king@...onical.com>
>>
>> The comparison of hw_ioctxt.rx_buf_sz_idx == -1 is always false because
>> rx_buf_sz_idx is a uint16_t. Fix this by explicitly casting -1 to uint16_t.
>>
>> Detected by CoverityScan, CID#1454559 ("Operands don't affect result")
>>
>> Signed-off-by: Colin Ian King <colin.king@...onical.com>
>> ---
>>  drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
>> index 09dec6de8dd5..71e26070fb7f 100644
>> --- a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
>> +++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
>> @@ -352,7 +352,7 @@ static int set_hw_ioctxt(struct hinic_hwdev *hwdev, unsigned int rq_depth,
>>  		}
>>  	}
>>  
>> -	if (hw_ioctxt.rx_buf_sz_idx == -1)
>> +	if (hw_ioctxt.rx_buf_sz_idx == (uint16_t)-1)
>>  		return -EINVAL;
>>  
>>  	hw_ioctxt.sq_depth  = ilog2(sq_depth);
>>
> 
> Many thanks, Colin.
> I prefer to avoid casting when possible, what do you think about replacing the condition by:
> 
> if (rx_buf_sz_table[i].sz != HINIC_RX_BUF_SZ)
> 	return -EINVAL;
> 

Does that work as expected when rx_buf_sz_table[i].sz == -1?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ