From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9C4ECA0A02; Fri, 26 Mar 2021 10:37:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2992240685; Fri, 26 Mar 2021 10:37:26 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id 4019D4067B for ; Fri, 26 Mar 2021 10:37:24 +0100 (CET) Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F6GzX5TvVzyPBs; Fri, 26 Mar 2021 17:35:20 +0800 (CST) Received: from localhost (10.174.242.151) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Fri, 26 Mar 2021 17:37:13 +0800 From: wangyunjian To: CC: , , , , , Yunjian Wang Date: Fri, 26 Mar 2021 17:37:13 +0800 Message-ID: <8a980b235eeba49721dfef9d0f23be375e8958b0.1616741870.git.wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.242.151] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] net/mlx5: fix using flow tunnel before null check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Yunjian Wang 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") Signed-off-by: Yunjian Wang --- drivers/net/mlx5/mlx5_flow.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index d46fc333d1..bb8d09cdef 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -7899,10 +7899,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); + } } -- 2.23.0