From: Wenzhuo Lu Date: Tue, 10 Nov 2020 06:46:01 +0000 (+0800) Subject: net/iavf: check cache pointer before dereference X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=9c70bbd88c042db24b03a6bbba3e2bf967dcd408;p=dpdk.git net/iavf: check cache pointer before dereference The return value of rte_mempool_default_cache should be checked as it can be NULL. Fixes: 9ab9514c150e ("net/iavf: enable AVX512 for Tx") Reported-by: Konstantin Ananyev Signed-off-by: Wenzhuo Lu Acked-by: Konstantin Ananyev --- diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx512.c b/drivers/net/iavf/iavf_rxtx_vec_avx512.c index 86807346be..584d12ea36 100644 --- a/drivers/net/iavf/iavf_rxtx_vec_avx512.c +++ b/drivers/net/iavf/iavf_rxtx_vec_avx512.c @@ -1424,7 +1424,12 @@ iavf_tx_free_bufs_avx512(struct iavf_tx_queue *txq) struct rte_mempool *mp = txep[0].mbuf->pool; struct rte_mempool_cache *cache = rte_mempool_default_cache(mp, rte_lcore_id()); - void **cache_objs = &cache->objs[cache->len]; + void **cache_objs; + + if (!cache || cache->len == 0) + goto normal; + + cache_objs = &cache->objs[cache->len]; if (n > RTE_MEMPOOL_CACHE_MAX_SIZE) { rte_mempool_ops_enqueue_bulk(mp, (void *)txep, n); @@ -1462,6 +1467,7 @@ iavf_tx_free_bufs_avx512(struct iavf_tx_queue *txq) goto done; } +normal: m = rte_pktmbuf_prefree_seg(txep[0].mbuf); if (likely(m)) { free[0] = m;