From: Wenzhuo Lu Date: Tue, 10 Nov 2020 06:45:52 +0000 (+0800) Subject: net/ice: check cache pointer before dereference X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4e61f1ac803ab508afeb47ca226b531ac22f6eb9;p=dpdk.git net/ice: check cache pointer before dereference The return value of rte_mempool_default_cache should be checked as it can be NULL. Fixes: a4e480de268e ("net/ice: optimize Tx by using AVX512") Reported-by: Konstantin Ananyev Signed-off-by: Wenzhuo Lu Acked-by: Konstantin Ananyev --- diff --git a/drivers/net/ice/ice_rxtx_vec_avx512.c b/drivers/net/ice/ice_rxtx_vec_avx512.c index e5e7cc1482..af6b324aa1 100644 --- a/drivers/net/ice/ice_rxtx_vec_avx512.c +++ b/drivers/net/ice/ice_rxtx_vec_avx512.c @@ -781,9 +781,14 @@ ice_tx_free_bufs_avx512(struct ice_tx_queue *txq) if (txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE && (n & 31) == 0) { struct rte_mempool *mp = txep[0].mbuf->pool; + void **cache_objs; struct rte_mempool_cache *cache = rte_mempool_default_cache(mp, rte_lcore_id()); - void **cache_objs = &cache->objs[cache->len]; + + 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); @@ -821,6 +826,7 @@ ice_tx_free_bufs_avx512(struct ice_tx_queue *txq) goto done; } +normal: m = rte_pktmbuf_prefree_seg(txep[0].mbuf); if (likely(m)) { free[0] = m;