Subject: [PATCH net 3/3] net/mlx5: Add null check for flow namespace in mlx5_cmd_set_slave_root_fdb

From: Oskar Ray-Frayssinet <[email-masked]>
Date: Thu, 26 Mar 2026 21:58:24 +0100

mlx5_get_flow_namespace() can return NULL if the namespace is not
available. Add a null check to prevent potential null pointer
dereference when accessing ns->node.

Signed-off-by: Oskar Ray-Frayssinet <[email-masked]>
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
index c348ee62cd3a..c52d8ca6aa0b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
@@ -186,6 +186,8 @@ static int mlx5_cmd_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);
 		MLX5_SET(set_flow_table_root_in, in, table_id,
 			 root->root_ft->id);
-- 
2.43.0