sched: fix memory leak on init failure
authorTonghao Zhang <xiangxia.m.yue@gmail.com>
Wed, 28 Nov 2018 13:55:55 +0000 (05:55 -0800)
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>
Fri, 21 Dec 2018 23:22:57 +0000 (00:22 +0100)
In some case, we may create sched port dynamically,
if err when creating so memory will leak.

Fixes: de3cfa2c9823 ("sched: initial import")
Cc: stable@dpdk.org
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
lib/librte_sched/rte_sched.c

index dd77391..77aed9f 100644 (file)
@@ -654,6 +654,7 @@ rte_sched_port_config(struct rte_sched_port_params *params)
                                params->red_params[i][j].min_th,
                                params->red_params[i][j].max_th,
                                params->red_params[i][j].maxp_inv) != 0) {
+                               rte_free(port);
                                return NULL;
                        }
                }
@@ -713,6 +714,7 @@ rte_sched_port_config(struct rte_sched_port_params *params)
                                    bmp_mem_size);
        if (port->bmp == NULL) {
                RTE_LOG(ERR, SCHED, "Bitmap init error\n");
+               rte_free(port);
                return NULL;
        }