From: Yunjian Wang Date: Sat, 27 Mar 2021 02:44:09 +0000 (+0800) Subject: net/mlx5: fix using flow tunnel before null check X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ed9726ce83eb7562b3dcfaf0ee10647ed816ae4a;p=dpdk.git net/mlx5: fix using flow tunnel before null check Coverity flags that 'ctx->tunnel' variable is used before it's checked for NULL. This patch fixes this issue. Coverity issue: 366201 Fixes: 868d2e342cf3 ("net/mlx5: fix tunnel offload hub multi-thread protection") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Acked-by: Viacheslav Ovsiienko --- diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 7ab7f63264..c347f8130e 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7881,10 +7881,11 @@ static void get_tunnel_miss(struct rte_eth_dev *dev, void *x) rte_spinlock_unlock(&thub->sl); ctx->tunnel = mlx5_flow_tunnel_allocate(dev, ctx->app_tunnel); - ctx->tunnel->refctn = 1; rte_spinlock_lock(&thub->sl); - if (ctx->tunnel) + if (ctx->tunnel) { + ctx->tunnel->refctn = 1; LIST_INSERT_HEAD(&thub->tunnels, ctx->tunnel, chain); + } }