net/mlx5: fix indexed pool local cache crash

Local cache for an indexed pool is not initialized in the situation when
all the indices are allocated on one CPU core and freed on another one.
That leads to a crash once we try to check its reference counter.
Check that the local cache is initialized before accessing this counter.

Fixes: d15c0946be ("net/mlx5: add indexed pool local cache")
Cc: stable@dpdk.org

Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
This commit is contained in:
Alexander Kozyrev 2022-11-09 14:58:19 +02:00 committed by Raslan Darawsheh
parent 73be9af44e
commit 7869d60380

View File

@ -479,7 +479,7 @@ _mlx5_ipool_free_cache(struct mlx5_indexed_pool *pool, int cidx, uint32_t idx)
mlx5_ipool_lock(pool);
gc = pool->gc;
if (ilc->lc != gc) {
if (!(--ilc->lc->ref_cnt))
if (ilc->lc && !(--ilc->lc->ref_cnt))
olc = ilc->lc;
gc->ref_cnt++;
ilc->lc = gc;