Re: [PATCH] IB/mlx5: Clarify success return path in mlx5_ib_alloc_transport_domain

From: Leon Romanovsky

Date: Tue Mar 31 2026 - 09:53:16 EST


On Tue, Mar 31, 2026 at 02:28:06AM +0100, Prathamesh Deshpande wrote:
> In mlx5_ib_alloc_transport_domain(), the function returns 'err' if
> loopback enablement is skipped. At this point, 'err' is always 0
> because the preceding transport domain allocation succeeded.
>
> Smatch warns that this is a "missing error code" because returning
> a variable instead of a literal 0 in an early-exit path is ambiguous.
> Explicitly return 0 to clarify that this is an intentional success path
> and to improve code robustness.
>
> Signed-off-by: Prathamesh Deshpande <prathameshdeshpande7@xxxxxxxxx>
> ---
> drivers/infiniband/hw/mlx5/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
> index 635002e684a5..ae4c8ed1c87d 100644
> --- a/drivers/infiniband/hw/mlx5/main.c
> +++ b/drivers/infiniband/hw/mlx5/main.c
> @@ -2068,7 +2068,7 @@ static int mlx5_ib_alloc_transport_domain(struct mlx5_ib_dev *dev, u32 *tdn,
> if ((MLX5_CAP_GEN(dev->mdev, port_type) != MLX5_CAP_PORT_TYPE_ETH) ||
> (!MLX5_CAP_GEN(dev->mdev, disable_local_lb_uc) &&
> !MLX5_CAP_GEN(dev->mdev, disable_local_lb_mc)))
> - return err;
> + return 0;

Let's fix it together with AI findings.
https://sashiko.dev/#/patchset/20260331012806.10077-1-prathameshdeshpande7@xxxxxxxxx

Thanks

>
> return mlx5_ib_enable_lb(dev, true, false);
> }
> --
> 2.43.0
>
>