net/mvpp2: fix null dereference in vmwa release

Message ID 20231104102836.2134140-1-liweiguo@xencore.cn (mailing list archive)
State Changes Requested, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mvpp2: fix null dereference in vmwa release |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Weiguo Li Nov. 4, 2023, 10:28 a.m. UTC
  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@dpdk.org

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

Comments

Raslan Darawsheh Nov. 12, 2023, 3:26 p.m. UTC | #1
Hi Weiguo,

> -----Original Message-----
> From: Weiguo Li <liweiguo@xencore.cn>
> Sent: Saturday, November 4, 2023 12:29 PM
> To: Ophir Munk <ophirmu@nvidia.com>
> Cc: lironh@marvell.com; dev@dpdk.org; stable@dpdk.org
> Subject: [PATCH] net/mvpp2: fix null dereference in vmwa release
> 
> Pointer 'mrvl_cfg' is dereferenced and then compared to NULL.
> Move dereference after NULL test to fix this issue.
> 
I think the commit log isn't relevant to the change really,
Can you kindly check that?

Kindest  regards
Raslan Darawsheh
  

Patch

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);