Commit 91c596cc authored by Jakub Kicinski's avatar Jakub Kicinski

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.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 49eb9446 5e2ea780
...@@ -183,6 +183,7 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) ...@@ -183,6 +183,7 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum)
eeprom_ptrs); eeprom_ptrs);
if (status != 0) { if (status != 0) {
wx_err(wxhw, "Failed to read EEPROM image\n"); wx_err(wxhw, "Failed to read EEPROM image\n");
kvfree(eeprom_ptrs);
return status; return status;
} }
local_buffer = eeprom_ptrs; local_buffer = eeprom_ptrs;
...@@ -196,13 +197,14 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) ...@@ -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) if (i != wxhw->eeprom.sw_region_offset + TXGBE_EEPROM_CHECKSUM)
*checksum += local_buffer[i]; *checksum += local_buffer[i];
*checksum = TXGBE_EEPROM_SUM - *checksum;
if (*checksum < 0)
return -EINVAL;
if (eeprom_ptrs) if (eeprom_ptrs)
kvfree(eeprom_ptrs); kvfree(eeprom_ptrs);
if (*checksum > TXGBE_EEPROM_SUM)
return -EINVAL;
*checksum = TXGBE_EEPROM_SUM - *checksum;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment