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, stable@dpdk.org
Subject: [PATCH] net/bnxt: validate pool index in pool manager APIs
Date: Mon,  5 Oct 2026 15:25:36 -0500	[thread overview]
Message-ID: <20261005202536.18083-1-manish.kurup@broadcom.com> (raw)

From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>

Validate the pool index in the pool manager APIs so that it cannot go
out of bounds when setting or getting data from the table-scope pool
manager.

Fixes: 80317ff6adfd ("net/bnxt/tf_core: support Thor2")
Cc: stable@dpdk.org

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
---
 drivers/net/bnxt/hcapi/cfa_v3/tpm/cfa_tpm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/bnxt/hcapi/cfa_v3/tpm/cfa_tpm.c b/drivers/net/bnxt/hcapi/cfa_v3/tpm/cfa_tpm.c
index 790b6c7e42..90d0206a15 100644
--- a/drivers/net/bnxt/hcapi/cfa_v3/tpm/cfa_tpm.c
+++ b/drivers/net/bnxt/hcapi/cfa_v3/tpm/cfa_tpm.c
@@ -6,6 +6,7 @@
 #define COMP_ID TPM
 
 #include <errno.h>
+#include <inttypes.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <string.h>
@@ -119,6 +120,12 @@ int cfa_tpm_free(void *tpm, uint16_t pool_id)
 		return -EINVAL;
 	}
 
+	if (pool_id >= ctx->max_pools) {
+		CFA_LOG_ERR("pool_id (%" PRIu16 ") out of range (max %" PRIu16 ")\n",
+			    pool_id, ctx->max_pools);
+		return -EINVAL;
+	}
+
 	if (ctx->fid_tbl[pool_id] != CFA_INVALID_FID) {
 		CFA_LOG_ERR("A function (%d) is still using the pool (%d)\n",
 			    ctx->fid_tbl[pool_id], pool_id);
@@ -137,6 +144,12 @@ int cfa_tpm_fid_add(void *tpm, uint16_t pool_id, uint16_t fid)
 		return -EINVAL;
 	}
 
+	if (pool_id >= ctx->max_pools) {
+		CFA_LOG_ERR("pool_id (%" PRIu16 ") out of range (max %" PRIu16 ")\n",
+			    pool_id, ctx->max_pools);
+		return -EINVAL;
+	}
+
 	if (!ba_inuse(ctx->pool_ba, pool_id)) {
 		CFA_LOG_ERR("Pool id (%d) was not allocated\n", pool_id);
 		return -EINVAL;
@@ -163,6 +176,12 @@ int cfa_tpm_fid_rem(void *tpm, uint16_t pool_id, uint16_t fid)
 		return -EINVAL;
 	}
 
+	if (pool_id >= ctx->max_pools) {
+		CFA_LOG_ERR("pool_id (%" PRIu16 ") out of range (max %" PRIu16 ")\n",
+			    pool_id, ctx->max_pools);
+		return -EINVAL;
+	}
+
 	if (!ba_inuse(ctx->pool_ba, pool_id)) {
 		CFA_LOG_ERR("Pool id (%d) was not allocated\n", pool_id);
 		return -EINVAL;
-- 
2.31.1


                 reply	other threads:[~2026-10-05 20:25 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=20261005202536.18083-1-manish.kurup@broadcom.com \
    --to=manish.kurup@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=kishore.padmanabha@broadcom.com \
    --cc=stable@dpdk.org \
    /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