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 26af75beb8b35963168b49f7e5d9da4b24aa85cf..93bf215762e329472b96183fda2496342ba923d0 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 1edea83a5b6b8ffc3b5e011b546317546e75d17d..db431f7d8b0bc39ca1db18d0403bc9de9b84a336 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 {