Skip to content

Commit

Permalink
net/mlx5: handle errors in mlx5_chains_create_table()
Browse files Browse the repository at this point in the history
In mlx5_chains_create_table(), the return value of mlx5_get_fdb_sub_ns()
and mlx5_get_flow_namespace() must be checked to prevent NULL pointer
dereferences. If either function fails, the function should log error
message with mlx5_core_warn() and return error pointer.

Fixes: 39ac237 ("net/mlx5: E-Switch, Refactor chains and priorities")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20250307021820.2646-1-vulab@iscas.ac.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Wentao Liang authored and Jakub Kicinski committed Mar 10, 2025
1 parent 505ead7 commit eab0396
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/lib/fs_chains.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ mlx5_chains_create_table(struct mlx5_fs_chains *chains,
ns = mlx5_get_flow_namespace(chains->dev, chains->ns);
}

if (!ns) {
mlx5_core_warn(chains->dev, "Failed to get flow namespace\n");
return ERR_PTR(-EOPNOTSUPP);
}

ft_attr.autogroup.num_reserved_entries = 2;
ft_attr.autogroup.max_num_groups = chains->group_num;
ft = mlx5_create_auto_grouped_flow_table(ns, &ft_attr);
Expand Down

0 comments on commit eab0396

Please sign in to comment.