Re: [PATCH v1] net/mlx5: Fix null-ptr-deref in mlx5_create_inner_ttc_table()
From: Paolo Abeni
Date: Tue Apr 08 2025 - 06:02:21 EST
On 4/5/25 12:00 PM, Henry Martin wrote:
> Add NULL check for mlx5_get_flow_namespace() returns in
> mlx5_create_inner_ttc_table() to prevent NULL pointer dereference.
>
> Fixes: 137f3d50ad2a ("net/mlx5: Support matching on l4_type for ttc_table")
> Signed-off-by: Henry Martin <bsdhenrymartin@xxxxxxxxx>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/lib/fs_ttc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_ttc.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_ttc.c
> index eb3bd9c7f66e..4e964ca5367e 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_ttc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_ttc.c
> @@ -655,6 +655,8 @@ struct mlx5_ttc_table *mlx5_create_inner_ttc_table(struct mlx5_core_dev *dev,
> }
>
> ns = mlx5_get_flow_namespace(dev, params->ns_type);
> + if (!ns)
> + return ERR_PTR(-EOPNOTSUPP);
I suspect the ns_type the caller always sets a valid 'ns_type', so the
NULL ptr is not really possible here.
At very least an empty line after the return statement will make the
code more readable and the commit message should be rewritten to better
describe the issue.
Similar considerations apply to the other mlx5 fixes.
Thanks,
Paolo