[PATCH net 2/3] net/mlx5: Add null check for flow namespace in esw_set_slave_root_fdb

From: Oskar Ray-Frayssinet

Date: Thu Mar 26 2026 - 17:01:20 EST


mlx5_get_flow_namespace() can return NULL if the namespace is not
available. Add null checks to prevent potential null pointer
dereference when accessing ns->node in both master and slave branches.

Signed-off-by: Oskar Ray-Frayssinet <rayfraytech@xxxxxxxxx>
---
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 7a9ee36b8dca..63aff6255c02 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -2821,6 +2821,8 @@ static int esw_set_slave_root_fdb(struct mlx5_core_dev *master,
if (master) {
ns = mlx5_get_flow_namespace(master,
MLX5_FLOW_NAMESPACE_FDB);
+ if (!ns)
+ return -EOPNOTSUPP;
root = find_root(&ns->node);
mutex_lock(&root->chain_lock);
MLX5_SET(set_flow_table_root_in, in,
@@ -2833,6 +2835,8 @@ static int esw_set_slave_root_fdb(struct mlx5_core_dev *master,
} else {
ns = mlx5_get_flow_namespace(slave,
MLX5_FLOW_NAMESPACE_FDB);
+ if (!ns)
+ return -EOPNOTSUPP;
root = find_root(&ns->node);
mutex_lock(&root->chain_lock);
MLX5_SET(set_flow_table_root_in, in, table_id,
--
2.43.0