From: Tonghao Zhang Date: Wed, 28 Nov 2018 13:55:55 +0000 (-0800) Subject: sched: fix memory leak on init failure X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=03b7fd7e545f453f1d7c13d11bf8a0b7cd59a943;p=dpdk.git sched: fix memory leak on init failure 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 --- diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index dd77391728..77aed9fb28 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -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; }