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

Timothy McDaniel timothy.mcdaniel at intel.com
Wed Jul 6 23:46:27 CEST 2022


The cq_weight array must be sized for the maximum number
of eventdev ports, not 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 at dpdk.org

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

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 {
-- 
2.25.1



More information about the stable mailing list