Coverity buf fixes for bnx2x
cover Coverity buf fixes for bnx2x
These are obvious issues spotted several releases ago by Coverity, and seem to have ended up assigned to me.
Hold off the merge until it is tested on real hardware; sorry, I don't have this NIC.
Stephen Hemminger (4):
net/bnx2x: remove dead conditional net/bnx2x: fix always true expression net/bnx2x: fix possible infinite loop at startup net/bnx2x: fix duplicate branch
drivers/net/bnx2x/bnx2x.c | 19 +++++++------------ drivers/net/bnx2x/bnx2x_stats.c | 3 --- 2 files changed, 7 insertions(+), 15 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/4 net/bnx2x: remove dead conditional
The second if test here is impossible because it contradicts previous line.
Coverity issue: 384428
--- drivers/net/bnx2x/bnx2x_stats.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/bnx2x/bnx2x_stats.c +0 -3
@@ -73,9 +73,6 @@ bnx2x_storm_stats_post(struct bnx2x_softc *sc)int rc;if (!sc->stats_pending) { -if (sc->stats_pending) -return ; - sc->fw_stats_req->hdr.drv_stats_counter =htole16 (sc->stats_counter++);
Signature · 1 line
2.45.2
PATCH 2/4 net/bnx2x: fix always true expression
In reply to Stephen HemmingerCoverity spotted that the check to enable single interrupt mode would evaluate as always true since:
The or condition sc->interrupt_mode != 2 || sc->interrupt_mode != 3 will always be true because sc->interrupt_mode cannot be equal to two different values at the same time, so it must be not equal to at least one of them.
Coverity issue: 362046
--- drivers/net/bnx2x/bnx2x.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/bnx2x/bnx2x.c +2 -4
@@ -11189,11 +11189,9 @@ static int bnx2x_init_hw_func(struct bnx2x_softc *sc)/* Turn on a single ISR mode in IGU if driver is going to use * INT#x or MSI */ -if ((sc->interrupt_mode !=INTR_MODE_MSIX ) - || (sc->interrupt_mode !=INTR_MODE_SINGLE_MSIX )) { +if (sc->interrupt_mode ==INTR_MODE_INTX || + sc->interrupt_mode ==INTR_MODE_MSI ) pf_conf |=IGU_PF_CONF_SINGLE_ISR_EN ; - } -/* * Timers workaround bug: function init part. * Need to wait 20msec after initializing ILT,
Signature · 1 line
2.45.2
PATCH 3/4 net/bnx2x: fix possible infinite loop at startup
In reply to Stephen HemmingerCoverity spotted that one of the loop conditions was always true. Fix by initializing the variable using same logic as Linux kernel driver.
Coverity issue: 362057
--- drivers/net/bnx2x/bnx2x.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/bnx2x/bnx2x.c +3 -2
@@ -10331,12 +10331,13 @@ static int bnx2x_init_hw_common(struct bnx2x_softc *sc)REG_WR (sc,PXP2_REG_RD_DISABLE_INPUTS ,0 );if (!CHIP_IS_E1x (sc)) { -int factor =0 ; +int factor =CHIP_REV_IS_EMUL (sc) ?1000 : + (CHIP_REV_IS_FPGA (sc) ?400 :0 );ecore_init_block (sc,BLOCK_PGLUE_B ,PHASE_COMMON );ecore_init_block (sc,BLOCK_ATC ,PHASE_COMMON ); -/* let the HW do it's magic... */ +/* let the HW do it's magic... */ do { DELAY(200000); val = REG_RD(sc, ATC_REG_ATC_INIT_DONE);
Signature · 1 line
2.45.2
PATCH 4/4 net/bnx2x: fix duplicate branch
In reply to Stephen HemmingerCoverity spotted that both legs of the conditional are the same. Looking at kernel driver there is additional code there, but the kernel driver supports Wake On Lan, and DPDK does not.
Coverity issue: 362072
--- drivers/net/bnx2x/bnx2x.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/bnx2x/bnx2x.c +2 -6
@@ -1623,16 +1623,12 @@ static int bnx2x_nic_unload_no_mcp(struct bnx2x_softc *sc) }/* request unload mode from the MCP: COMMON, PORT or FUNCTION */ -static uint32_t bnx2x_send_unload_req (struct bnx2x_softc *sc,int unload_mode) +static uint32_t bnx2x_send_unload_req(struct bnx2x_softc *sc, int unload_mode __rte_unused) {uint32_t reset_code =0 ;/* Select the UNLOAD request mode */ -if (unload_mode ==UNLOAD_NORMAL ) { - reset_code =DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS ; - }else { - reset_code =DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS ; - } + reset_code =DRV_MSG_CODE_UNLOAD_REQ_WOL_DIS ;/* Send the request to the MCP */ if (!BNX2X_NOMCP (sc)) {
Signature · 1 line
2.45.2
RE: [EXTERNAL] [PATCH 4/4] net/bnx2x: fix duplicate branch
Quoted 18 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, November 12, 2024 11:14 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>; Julien Aube <[email protected]>; Harish Patil <[email protected]>
Subject: [EXTERNAL] [PATCH 4/4] net/bnx2x: fix duplicate branchCoverity spotted that both legs of the conditional are the same. Looking at kernel driver there is additional code there, but the kernel driver supports Wake On Lan, and DPDK does not. Coverity issue: 362072 Fixes:
540a211084a7("bnx2x: driver
Coverity spotted that both legs of the conditional are the same. Looking at kernel driver there is additional code there, but the kernel driver supports Wake On Lan, and DPDK does not.
Quoted 4 lines
Coverity issue: 362072
Fixes 540a211084a7 ("bnx2x: driver core")Signed-off-by Stephen Hemminger <[email protected]>
Added Cc: [email protected] and Series applied to dpdk-next-net-mrvl/for-main. Thanks