Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+6 -4
+6 -4
drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c
··· 183 183 eeprom_ptrs); 184 184 if (status != 0) { 185 185 wx_err(wxhw, "Failed to read EEPROM image\n"); 186 + kvfree(eeprom_ptrs); 186 187 return status; 187 188 } 188 189 local_buffer = eeprom_ptrs; ··· 197 196 if (i != wxhw->eeprom.sw_region_offset + TXGBE_EEPROM_CHECKSUM) 198 197 *checksum += local_buffer[i]; 199 198 200 - *checksum = TXGBE_EEPROM_SUM - *checksum; 201 - if (*checksum < 0) 202 - return -EINVAL; 203 - 204 199 if (eeprom_ptrs) 205 200 kvfree(eeprom_ptrs); 201 + 202 + if (*checksum > TXGBE_EEPROM_SUM) 203 + return -EINVAL; 204 + 205 + *checksum = TXGBE_EEPROM_SUM - *checksum; 206 206 207 207 return 0; 208 208 }