[PATCH 2/4] net/bnx2x: fix always true expression

Stephen Hemminger stephen at networkplumber.org
Tue Nov 12 18:43:54 CET 2024


Coverity 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
Fixes: 540a211084a7 ("bnx2x: driver core")

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 drivers/net/bnx2x/bnx2x.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index 3153cc4d80..af31ac4604 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -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,
-- 
2.45.2



More information about the dev mailing list