Re: [PATCH] net/mlx5: Fix null-ptr-deref in mlx5_create_inner_ttc_table()

From: Mark Bloch
Date: Tue Apr 08 2025 - 11:03:20 EST




On 08/04/2025 15:25, Markus Elfring wrote:
>
>>> +++ 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.
>
> Is there a need to mark such a check result as “unlikely”?
>

Please don't. I'm fine with simply adding the check, as
Paolo suggested. When TTC was originally introduced, its
functionality was more limited, and reaching this point in the driver
meant we could be certain the namespace existed. Now that TTC has
become more advanced, adding this check makes sense and I'm okay with
it.

Mark

> Regards,
> Markus
>