提交 91c596cc 编写于 作者: J 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: NJakub Kicinski <kuba@kernel.org>
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册