Commit a068d33e authored by YueHaibing's avatar YueHaibing Committed by Jakub Kicinski

net: txgbe: Fix memleak in txgbe_calc_eeprom_checksum()

eeprom_ptrs should be freed before returned.

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 49eb9446
...@@ -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,13 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) ...@@ -196,13 +197,13 @@ 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];
if (eeprom_ptrs)
kvfree(eeprom_ptrs);
*checksum = TXGBE_EEPROM_SUM - *checksum; *checksum = TXGBE_EEPROM_SUM - *checksum;
if (*checksum < 0) if (*checksum < 0)
return -EINVAL; return -EINVAL;
if (eeprom_ptrs)
kvfree(eeprom_ptrs);
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