[PATCH] net/mvpp2: fix null dereference in vmwa release

Weiguo Li liweiguo at xencore.cn
Sat Nov 4 11:28:36 CET 2023


Pointer 'mrvl_cfg' is dereferenced and then compared to NULL.
Move dereference after NULL test to fix this issue.

Fixes: 7af10d29a4a0 ("net/mlx5/linux: refactor VLAN")
Cc: stable at dpdk.org

Signed-off-by: Weiguo Li <liweiguo at xencore.cn>
---
 drivers/net/mlx5/linux/mlx5_vlan_os.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/linux/mlx5_vlan_os.c b/drivers/net/mlx5/linux/mlx5_vlan_os.c
index 81611a8d3f..391c9ce832 100644
--- a/drivers/net/mlx5/linux/mlx5_vlan_os.c
+++ b/drivers/net/mlx5/linux/mlx5_vlan_os.c
@@ -37,12 +37,13 @@ mlx5_vlan_vmwa_release(struct rte_eth_dev *dev,
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_nl_vlan_vmwa_context *vmwa = priv->vmwa_context;
-	struct mlx5_nl_vlan_dev *vlan_dev = &vmwa->vlan_dev[0];
+	struct mlx5_nl_vlan_dev *vlan_dev;
 
 	MLX5_ASSERT(vlan->created);
 	MLX5_ASSERT(priv->vmwa_context);
 	if (!vlan->created || !vmwa)
 		return;
+	vlan_dev = &vmwa->vlan_dev[0];
 	vlan->created = 0;
 	rte_spinlock_lock(&vmwa->sl);
 	MLX5_ASSERT(vlan_dev[vlan->tag].refcnt);
-- 
2.34.1



More information about the stable mailing list