From d37f5f279bb72f72ac47a31da7761d81e70b48ae Mon Sep 17 00:00:00 2001 From: Li Qiang Date: Tue, 9 Apr 2019 07:56:21 -0700 Subject: [PATCH] mempool/dpaa: fix leak in pool creation failure When 'rte_zmalloc' failed dpaa_mbuf_create_pool() forgets freeing 'bp' thus leading resource leak. This patch avoids this. Coverity issue: 337679 Signed-off-by: Li Qiang Acked-by: Hemant Agrawal --- drivers/mempool/dpaa/dpaa_mempool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c index 0030817725..54cdf37e8b 100644 --- a/drivers/mempool/dpaa/dpaa_mempool.c +++ b/drivers/mempool/dpaa/dpaa_mempool.c @@ -78,8 +78,10 @@ dpaa_mbuf_create_pool(struct rte_mempool *mp) rte_dpaa_bpid_info = (struct dpaa_bp_info *)rte_zmalloc(NULL, sizeof(struct dpaa_bp_info) * DPAA_MAX_BPOOLS, RTE_CACHE_LINE_SIZE); - if (rte_dpaa_bpid_info == NULL) + if (rte_dpaa_bpid_info == NULL) { + bman_free_pool(bp); return -ENOMEM; + } } rte_dpaa_bpid_info[bpid].mp = mp; -- 2.20.1