DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Manish Kurup <manish.kurup@broadcom.com>
To: dev@dpdk.org
Cc: kishore.padmanabha@broadcom.com,
	Mohammad Shuab Siddique <mohammad-shuab.siddique@broadcom.com>
Subject: [PATCH] net/bnxt: harden CPU index validation in stats cache thread
Date: Mon,  5 Oct 2026 18:50:56 -0500	[thread overview]
Message-ID: <20261005235056.27126-1-manish.kurup@broadcom.com> (raw)

From: Mohammad Shuab Siddique <mohammad-shuab.siddique@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@broadcom.com>
Signed-off-by: Manish Kurup <manish.kurup@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


                 reply	other threads:[~2026-10-05 23:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261005235056.27126-1-manish.kurup@broadcom.com \
    --to=manish.kurup@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=kishore.padmanabha@broadcom.com \
    --cc=mohammad-shuab.siddique@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox