public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Shuhao Fu <sfual@cse.ust.hk>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RDMA/mlx5: Fix refcount inconsistency in mlx5_netdev_event
Date: Mon, 27 Oct 2025 14:59:35 +0200	[thread overview]
Message-ID: <20251027125935.GJ12554@unreal> (raw)
In-Reply-To: <aPe3mnFjQeXaILyR@chcpu18>

On Tue, Oct 21, 2025 at 04:40:58PM +0000, Shuhao Fu wrote:
> Fix refcount inconsistency related to `mlx5_ib_get_native_port_mdev`.
> 
> Function `mlx5_ib_get_native_port_mdev` could increase the counter of 
> `mpi->mdev_refcnt` if mpi is not master. To ensure refcount consistency,
> each call to `mlx5_ib_get_native_port_mdev` should have a corresponding
> call to `mlx5_ib_put_native_port_mdev`. In `mlx5_netdev_event`, two
> branches fail to do so, leading to a possible bug when unbinding.
> 
> Fixes: 379013776222 ("RDMA/mlx5: Handle link status event only for LAG device")
> Fixes: 35b0aa67b298 ("RDMA/mlx5: Refactor netdev affinity code")
> Signed-off-by: Shuhao Fu <sfual@cse.ust.hk>
> ---
>  drivers/infiniband/hw/mlx5/main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
> index fc1e86f6c..0c4aa7c50 100644
> --- a/drivers/infiniband/hw/mlx5/main.c
> +++ b/drivers/infiniband/hw/mlx5/main.c
> @@ -247,7 +247,7 @@ static int mlx5_netdev_event(struct notifier_block *this,
>  
>  		if (!netif_is_lag_master(ndev) && !netif_is_lag_port(ndev) &&
>  		    !mlx5_core_mp_enabled(mdev))
> -			return NOTIFY_DONE;
> +			goto done;

mdev_refcnt is increased only for MPV slave, but here we are checking if
MPV is enabled. It is not in this leaf and "return NOTIFY_DONE" is the
right thing to do.

>  
>  		if (mlx5_lag_is_roce(mdev) || mlx5_lag_is_sriov(mdev)) {
>  			struct net_device *lag_ndev;
> @@ -268,7 +268,7 @@ static int mlx5_netdev_event(struct notifier_block *this,
>  		if (ibdev->is_rep)
>  			roce = mlx5_get_rep_roce(ibdev, ndev, upper, &port_num);
>  		if (!roce)
> -			return NOTIFY_DONE;
> +			goto done;

It is not MPV flow either. There is nothing to change here.

Thanks

>  
>  		ib_ndev = ib_device_get_netdev(&ibdev->ib_dev, port_num);
>  
> -- 
> 2.39.5 (Apple Git-154)
> 

      reply	other threads:[~2025-10-27 12:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-21 16:40 [PATCH] RDMA/mlx5: Fix refcount inconsistency in mlx5_netdev_event Shuhao Fu
2025-10-27 12:59 ` Leon Romanovsky [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251027125935.GJ12554@unreal \
    --to=leon@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sfual@cse.ust.hk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox