]> git.droids-corp.org - dpdk.git/commitdiff
sched: fix profile allocation failure handling
authorHuisong Li <lihuisong@huawei.com>
Fri, 23 Apr 2021 11:01:11 +0000 (19:01 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 24 Jul 2021 08:58:39 +0000 (10:58 +0200)
This patch fixes return value judgment when allocate memory to store the
subport profile, and releases memory of 'rte_sched_port' if code fails to
apply for this memory.

Fixes: 0ea4c6afcaf1 ("sched: add subport profile table")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
lib/sched/rte_sched.c

index cd87e688e489feee8ee4f1ddef4b5e151372fd75..df0ab5cab9dd0a4fe7cc1cad18a3fe913e76ac05 100644 (file)
@@ -961,9 +961,9 @@ rte_sched_port_config(struct rte_sched_port_params *params)
        /* Allocate memory to store the subport profile */
        port->subport_profiles  = rte_zmalloc_socket("subport_profile", size2,
                                        RTE_CACHE_LINE_SIZE, params->socket);
-       if (port == NULL) {
+       if (port->subport_profiles == NULL) {
                RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__);
-
+               rte_free(port);
                return NULL;
        }