[PATCH] net/bnxt: harden CPU index validation in stats cache thread

Manish Kurup manish.kurup at broadcom.com
Tue Oct 6 01:50:56 CEST 2026


From: Mohammad Shuab Siddique <mohammad-shuab.siddique at broadcom.com>

Use a < 0 guard instead of == -1 when checking the return values of
ulp_sc_find_free_cpu() and ulp_sc_get_first_dpdk_cpu() before passing
target_cpu to CPU_SET(). Both helpers only ever return -1 today, so
this does not change behavior for the current implementation, but it
makes the non-negative invariant on target_cpu explicit at the
CPU_SET() call site instead of relying on -1 being the only possible
failure value.

Signed-off-by: Mohammad Shuab Siddique <mohammad-shuab.siddique at broadcom.com>
Signed-off-by: Manish Kurup <manish.kurup at broadcom.com>
---
 drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
index 221b57cbf7..92defadc20 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
@@ -422,9 +422,9 @@ ulp_sc_mgr_thread_start(struct bnxt_ulp_context *ctxt)
 		/* Try to find a free CPU not used by DPDK lcores */
 		target_cpu = ulp_sc_find_free_cpu();
 		/* If no free CPU found, use first CPU from first DPDK lcore */
-		if (target_cpu == -1) {
+		if (target_cpu < 0) {
 			target_cpu = ulp_sc_get_first_dpdk_cpu();
-			if (target_cpu == -1)
+			if (target_cpu < 0)
 				return -ENOENT;
 		}
 
-- 
2.31.1



More information about the dev mailing list