[1/2] event/dlb2: fix cq_weight array overflow

Message ID 20220706213141.2374006-2-timothy.mcdaniel@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers
Series DLB2: cq_weight fixes |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Timothy McDaniel July 6, 2022, 9:31 p.m. UTC
  The cq_weight array must be sized for the maximum number
of eventdev ports, not the the maximum number of DLB2
load balanced ports.

This commit fixes the above array sizing bug and resultant
coverity warning.

Coverity issue: 379234
Fixes: ffa46fc4a2b5 ("event/dlb2: support CQ weight")
Cc: stable@dpdk.org

Signed-off-by: Timothy McDaniel <timothy.mcdaniel@intel.com>
---
 drivers/event/dlb2/dlb2.c      | 4 ++--
 drivers/event/dlb2/dlb2_priv.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c
index 26af75beb8..93bf215762 100644
--- a/drivers/event/dlb2/dlb2.c
+++ b/drivers/event/dlb2/dlb2.c
@@ -137,7 +137,7 @@  set_cq_weight(const char *key __rte_unused,
 	 */
 	if (sscanf(value, "all:%d", &weight) == 1) {
 		first = 0;
-		last = DLB2_MAX_NUM_LDB_PORTS - 1;
+		last = DLB2_MAX_NUM_PORTS_ALL - 1;
 	} else if (sscanf(value, "%d-%d:%d", &first, &last, &weight) == 3) {
 		/* we have everything we need */
 	} else if (sscanf(value, "%d:%d", &first, &weight) == 2) {
@@ -148,7 +148,7 @@  set_cq_weight(const char *key __rte_unused,
 	}
 
 	if (first > last || first < 0 ||
-		last >= DLB2_MAX_NUM_LDB_PORTS) {
+		last >= DLB2_MAX_NUM_PORTS_ALL) {
 		DLB2_LOG_ERR("Error parsing ldb port qe weight arg, invalid port value\n");
 		return -EINVAL;
 	}
diff --git a/drivers/event/dlb2/dlb2_priv.h b/drivers/event/dlb2/dlb2_priv.h
index 1edea83a5b..db431f7d8b 100644
--- a/drivers/event/dlb2/dlb2_priv.h
+++ b/drivers/event/dlb2/dlb2_priv.h
@@ -641,7 +641,7 @@  struct dlb2_qid_depth_thresholds {
 };
 
 struct dlb2_cq_weight {
-	int limit[DLB2_MAX_NUM_LDB_PORTS];
+	int limit[DLB2_MAX_NUM_PORTS_ALL];
 };
 
 struct dlb2_port_cos {