From: Olivier Matz Date: Mon, 19 Sep 2016 12:34:41 +0000 (+0200) Subject: mbuf: fix error handling on pool creation X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4e8739e9bb5aa125dbc964ad49caaf876d616b41;p=dpdk.git mbuf: fix error handling on pool creation On error, the mempool object has to be freed, and rte_errno should be a positive value. Fixes: 152ca517900b ("mbuf: use default mempool handler from config") Signed-off-by: Olivier Matz --- diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 80b1713b27..72f928012d 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -173,10 +173,12 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, if (mp == NULL) return NULL; - rte_errno = rte_mempool_set_ops_byname(mp, - RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL); - if (rte_errno != 0) { + ret = rte_mempool_set_ops_byname(mp, + RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL); + if (ret != 0) { RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); + rte_mempool_free(mp); + rte_errno = -ret; return NULL; } rte_pktmbuf_pool_init(mp, &mbp_priv);