From 25e6755056eaba45921b898b9986af68277ac6ac Mon Sep 17 00:00:00 2001 From: Andrew Rybchenko Date: Mon, 16 Apr 2018 14:24:30 +0100 Subject: [PATCH] mempool: fix leak when no objects are populated Fixes: 84121f197187 ("mempool: store memory chunks in a list") Cc: stable@dpdk.org Suggested-by: Olivier Matz Signed-off-by: Andrew Rybchenko Acked-by: Olivier Matz --- lib/librte_mempool/rte_mempool.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 103c015e57..3b31a55513 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -421,12 +421,18 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, } /* not enough room to store one object */ - if (i == 0) - return -EINVAL; + if (i == 0) { + ret = -EINVAL; + goto fail; + } STAILQ_INSERT_TAIL(&mp->mem_list, memhdr, next); mp->nb_mem_chunks++; return i; + +fail: + rte_free(memhdr); + return ret; } int -- 2.20.1