diff options
author | YueHaibing <yuehaibing@huawei.com> | 2022-11-05 16:07:22 +0800 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-11-07 20:00:10 -0800 |
commit | 5e2ea7801faccc011359db5ad6af5987b513f314 (patch) | |
tree | 04153647c8d6da1c931285c6233a91fb1d555083 | |
parent | a068d33e542f5d5be2e5de3cf1122c4347d3e2af (diff) |
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: 049fe5365324 ("net: txgbe: Add operations to interact with firmware")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r-- | drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c index 9cf5fe33118e..167f7ff73192 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c @@ -200,10 +200,11 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) if (eeprom_ptrs) kvfree(eeprom_ptrs); - *checksum = TXGBE_EEPROM_SUM - *checksum; - if (*checksum < 0) + if (*checksum > TXGBE_EEPROM_SUM) return -EINVAL; + *checksum = TXGBE_EEPROM_SUM - *checksum; + return 0; } |