Subject: Re: [PATCH net-next 2/7] net/mlx5e: Use TIR API in mlx5e_modify_tirs_lb()

From: Simon Horman <[email-masked]>
Date: Thu, 23 Oct 2025 14:31:00 +0100

On Thu, Oct 23, 2025 at 09:43:35AM +0300, Tariq Toukan wrote:

...

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
> index 376a018b2db1..fad6b761f622 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
> @@ -250,43 +250,30 @@ void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev)
>  int mlx5e_modify_tirs_lb(struct mlx5_core_dev *mdev, bool enable_uc_lb,
>  			 bool enable_mc_lb)

...

>  	list_for_each_entry(tir, &mdev->mlx5e_res.hw_objs.td.tirs_list, list) {
> -		tirn = tir->tirn;
> -		err = mlx5_core_modify_tir(mdev, tirn, in);
> +		err = mlx5e_tir_modify(tir, builder);
>  		if (err)
>  			break;
>  	}
>  	mutex_unlock(&mdev->mlx5e_res.hw_objs.td.list_lock);
>  
> -	kvfree(in);
> +	mlx5e_tir_builder_free(builder);
>  	if (err)
>  		mlx5_core_err(mdev,
>  			      "modify tir(0x%x) enable_lb uc(%d) mc(%d) failed, %d\n",
> -			      tirn,
> +			      mlx5e_tir_get_tirn(tir),

Sorry, for not noticing this before sending my previous email.

Coccinelle complains about the line above like this:

.../en_common.c:276:28-31: ERROR: invalid reference to the index variable of the iterator on line 265

I think this is a false positive because the problem only occurs if
the list iteration runs to completion. But err guards against
tir being used in that case.

But, perhaps, to be on the safe side, it would be good practice
to stash tir somewhere?

>  			      enable_uc_lb, enable_mc_lb, err);
>  
>  	return err;
> -- 
> 2.31.1
> 
>