Message ID | 20221105080722.20292-3-yuehaibing@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 5e2ea7801faccc011359db5ad6af5987b513f314 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: txgbe: Fix two bugs in txgbe_calc_eeprom_checksum | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/cc_maintainers | success | CCed 8 of 8 maintainers |
netdev/build_clang | success | Errors and warnings before: 0 this patch: 0 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | Fixes tag looks correct |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 13 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Saturday, November 5, 2022 4:07 PM, YueHaibing wrote: > The error checks on checksum for a negative error return always fails because > it is unsigned and can never be negative. > > Fixes: 049fe5365324 ("net: txgbe: Add operations to interact with firmware") > Signed-off-by: YueHaibing <yuehaibing@huawei.com> > --- > drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c > index 9cf5fe33118e..167f7ff73192 100644 > --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c > +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c > @@ -200,10 +200,11 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) > if (eeprom_ptrs) > kvfree(eeprom_ptrs); > > - *checksum = TXGBE_EEPROM_SUM - *checksum; > - if (*checksum < 0) > + if (*checksum > TXGBE_EEPROM_SUM) > return -EINVAL; > > + *checksum = TXGBE_EEPROM_SUM - *checksum; > + > return 0; > } It is a pity, I didn't review this patch carefully. *checksum will sometimes be larger than TXGBE_EEPROM_SUM. It's correct to remove these two lines: - if (*checksum < 0) - return -EINVAL; I'll send a patch to fix it.
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c index 9cf5fe33118e..167f7ff73192 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c @@ -200,10 +200,11 @@ static int txgbe_calc_eeprom_checksum(struct txgbe_hw *hw, u16 *checksum) if (eeprom_ptrs) kvfree(eeprom_ptrs); - *checksum = TXGBE_EEPROM_SUM - *checksum; - if (*checksum < 0) + if (*checksum > TXGBE_EEPROM_SUM) return -EINVAL; + *checksum = TXGBE_EEPROM_SUM - *checksum; + return 0; }
The error checks on checksum for a negative error return always fails because it is unsigned and can never be negative. Fixes: 049fe5365324 ("net: txgbe: Add operations to interact with firmware") Signed-off-by: YueHaibing <yuehaibing@huawei.com> --- drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)