diff options
-rw-r--r-- | drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c index 0b1032195859..167f7ff73192 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c @@ -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; } |