From 03b7fd7e545f453f1d7c13d11bf8a0b7cd59a943 Mon Sep 17 00:00:00 2001 From: Tonghao Zhang Date: Wed, 28 Nov 2018 05:55:55 -0800 Subject: [PATCH] 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 --- lib/librte_sched/rte_sched.c | 2 ++ 1 file changed, 2 insertions(+) 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; } -- 2.20.1