app/testpmd: fix crash when mempool allocation fails
authorOlivier Matz <olivier.matz@6wind.com>
Fri, 9 Sep 2016 09:42:08 +0000 (11:42 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 23 Sep 2016 18:16:23 +0000 (20:16 +0200)
Avoid access to mempool pointer if it is NULL.

Coverity issue: 127553
Fixes: b19a0c75a0d4 ("app/testpmd: remove anonymous mempool code")

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
app/test-pmd/testpmd.c

index 30749a4..754de47 100644 (file)
@@ -443,10 +443,13 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
                                mb_size, (unsigned) mb_mempool_cache,
                                sizeof(struct rte_pktmbuf_pool_private),
                                socket_id, 0);
+                       if (rte_mp == NULL)
+                               goto err;
 
                        if (rte_mempool_populate_anon(rte_mp) == 0) {
                                rte_mempool_free(rte_mp);
                                rte_mp = NULL;
+                               goto err;
                        }
                        rte_pktmbuf_pool_init(rte_mp, NULL);
                        rte_mempool_obj_iter(rte_mp, rte_pktmbuf_init, NULL);
@@ -457,6 +460,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
                }
        }
 
+err:
        if (rte_mp == NULL) {
                rte_exit(EXIT_FAILURE,
                        "Creation of mbuf pool for socket %u failed: %s\n",