event/dlb2: fix CQ weight array overflow
authorTimothy McDaniel <timothy.mcdaniel@intel.com>
Wed, 6 Jul 2022 21:46:27 +0000 (16:46 -0500)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 11 Jul 2022 20:29:27 +0000 (22:29 +0200)
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@dpdk.org
Signed-off-by: Timothy McDaniel <timothy.mcdaniel@intel.com>
drivers/event/dlb2/dlb2.c
drivers/event/dlb2/dlb2_priv.h

index 26af75b..93bf215 100644 (file)
@@ -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;
        }
index 1edea83..db431f7 100644 (file)
@@ -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 {