mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
Merge branch 'net-txgbe-fix-two-bugs-in-txgbe_calc_eeprom_checksum'
YueHaibing says: ==================== net: txgbe: Fix two bugs in txgbe_calc_eeprom_checksum Fix memleak and unsigned comparison bugs in txgbe_calc_eeprom_checksum ==================== Link: https://lore.kernel.org/r/20221105080722.20292-1-yuehaibing@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
91c596cc8d
1 changed files with 6 additions and 4 deletions
|
|
@ -183,6 +183,7 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum)
|
|||
eeprom_ptrs);
|
||||
if (status != 0) {
|
||||
wx_err(wxhw, "Failed to read EEPROM image\n");
|
||||
kvfree(eeprom_ptrs);
|
||||
return status;
|
||||
}
|
||||
local_buffer = eeprom_ptrs;
|
||||
|
|
@ -196,13 +197,14 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum)
|
|||
if (i != wxhw->eeprom.sw_region_offset + TXGBE_EEPROM_CHECKSUM)
|
||||
*checksum += local_buffer[i];
|
||||
|
||||
*checksum = TXGBE_EEPROM_SUM - *checksum;
|
||||
if (*checksum < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (eeprom_ptrs)
|
||||
kvfree(eeprom_ptrs);
|
||||
|
||||
if (*checksum > TXGBE_EEPROM_SUM)
|
||||
return -EINVAL;
|
||||
|
||||
*checksum = TXGBE_EEPROM_SUM - *checksum;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue