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 97AE8A0A0A for ; Sat, 27 Mar 2021 03:45:00 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 82310140D97; Sat, 27 Mar 2021 03:45:00 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id 544754067B; Sat, 27 Mar 2021 03:44:57 +0100 (CET) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F6jn927PQzyNXQ; Sat, 27 Mar 2021 10:42:53 +0800 (CST) Received: from localhost (10.174.242.151) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Sat, 27 Mar 2021 10:44:45 +0800 From: wangyunjian To: CC: , , , , , Yunjian Wang , Date: Sat, 27 Mar 2021 10:44:09 +0800 Message-ID: <1616813049-19624-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <8a980b235eeba49721dfef9d0f23be375e8958b0.1616741870.git.wangyunjian@huawei.com> References: <8a980b235eeba49721dfef9d0f23be375e8958b0.1616741870.git.wangyunjian@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.242.151] X-CFilter-Loop: Reflected Subject: [dpdk-stable] [dpdk-dev] [PATCH v2] net/mlx5: fix using flow tunnel before null check X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Acked-by: Viacheslav Ovsiienko --- v2: add cc: stable@dpdk.org --- 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