[v2] net/mlx5: fix using flow tunnel before null check
Checks
Commit Message
From: Yunjian Wang <wangyunjian@huawei.com>
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 <wangyunjian@huawei.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
v2:
add cc: stable@dpdk.org
---
drivers/net/mlx5/mlx5_flow.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
Hi,
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of wangyunjian
> Sent: Saturday, March 27, 2021 5:44 AM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Shahaf Shuler
> <shahafs@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>;
> jerry.lilijun@huawei.com; chenchanghu@huawei.com; Yunjian Wang
> <wangyunjian@huawei.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v2] net/mlx5: fix using flow tunnel before null
> check
>
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> 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 <wangyunjian@huawei.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> ---
> v2:
> add cc: stable@dpdk.org
> ---
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
@@ -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);
+ }
}