提交 5e2ea780 编写于 作者: Y YueHaibing 提交者: Jakub Kicinski

net: txgbe: Fix unsigned comparison to zero in txgbe_calc_eeprom_checksum()

The error checks on checksum for a negative error return always fails because
it is unsigned and can never be negative.

Fixes: 049fe536 ("net: txgbe: Add operations to interact with firmware")
Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
Signed-off-by: NJakub Kicinski <kuba@kernel.org>
上级 a068d33e
...@@ -200,10 +200,11 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) ...@@ -200,10 +200,11 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum)
if (eeprom_ptrs) if (eeprom_ptrs)
kvfree(eeprom_ptrs); kvfree(eeprom_ptrs);
*checksum = TXGBE_EEPROM_SUM - *checksum; if (*checksum > TXGBE_EEPROM_SUM)
if (*checksum < 0)
return -EINVAL; return -EINVAL;
*checksum = TXGBE_EEPROM_SUM - *checksum;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册