net/iavf: check cache pointer before dereference

The return value of rte_mempool_default_cache should be
checked as it can be NULL.

Fixes: 9ab9514c15 ("net/iavf: enable AVX512 for Tx")

Reported-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
This commit is contained in:
Wenzhuo Lu 2020-11-10 14:46:01 +08:00 committed by Ferruh Yigit
parent 4e61f1ac80
commit 9c70bbd88c

View File

@ -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 *mp = txep[0].mbuf->pool;
struct rte_mempool_cache *cache = rte_mempool_default_cache(mp, struct rte_mempool_cache *cache = rte_mempool_default_cache(mp,
rte_lcore_id()); 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) { if (n > RTE_MEMPOOL_CACHE_MAX_SIZE) {
rte_mempool_ops_enqueue_bulk(mp, (void *)txep, n); 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; goto done;
} }
normal:
m = rte_pktmbuf_prefree_seg(txep[0].mbuf); m = rte_pktmbuf_prefree_seg(txep[0].mbuf);
if (likely(m)) { if (likely(m)) {
free[0] = m; free[0] = m;