Skip to content
Snippets Groups Projects
Commit 5e2ea780 authored by YueHaibing's avatar YueHaibing Committed by Jakub Kicinski
Browse files

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: default avatarYueHaibing <yuehaibing@huawei.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a068d33e
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment