Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Laurence Oberman <loberman@redhat.com>
To: Martin George <martinus.gpy@gmail.com>, linux-nvme@lists.infradead.org
Cc: hch@lst.de, kbusch@kernel.org, sagi@grimberg.me
Subject: Re: [PATCH] nvme-fc: fix reference leak in nvme_fc_nvme_discovery_store()
Date: Fri, 23 Oct 2026 10:39:03 -0400	[thread overview]
Message-ID: <cc8cee8648fd4a1614b71a49606c9520f87ae1e4.camel@redhat.com> (raw)
In-Reply-To: <20261023140057.6045-1-marting@netapp.com>

On Fri, 2026-10-23 at 19:30 +0530, Martin George wrote:
> nvme_fc_nvme_discovery_store() takes an lport and rport reference
> before
> checking whether the rport is already queued on the local discovery
> list. On the retry path (goto restart), rports that were queued in an
> earlier pass are skipped by the list_empty() check, but the
> references
> taken for them in the current pass are never dropped, leaking one
> lport
> and one rport reference per retry.
> 
> Check list_empty() first and only take references for rports that are
> actually added to the local discovery list.
> 
> Signed-off-by: Martin George <marting@netapp.com>
> ---
>  drivers/nvme/host/fc.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
> index 48454cb7a0fc..03f6fffc9574 100644
> --- a/drivers/nvme/host/fc.c
> +++ b/drivers/nvme/host/fc.c
> @@ -3778,6 +3778,9 @@ static ssize_t
> nvme_fc_nvme_discovery_store(struct device *dev,
>  restart:
>  	list_for_each_entry(lport, &nvme_fc_lport_list, port_list) {
>  		list_for_each_entry(rport, &lport->endp_list,
> endp_list) {
> +			/* skip rports already queued for discovery
> */
> +			if (!list_empty(&rport->disc_list))
> +				continue;
>  			if (!nvme_fc_lport_get(lport))
>  				continue;
>  			if (!nvme_fc_rport_get(rport)) {
> @@ -3799,9 +3802,7 @@ static ssize_t
> nvme_fc_nvme_discovery_store(struct device *dev,
>  				       "failures\n");
>  				goto process_local_list;
>  			}
> -			if (list_empty(&rport->disc_list))
> -				list_add_tail(&rport->disc_list,
> -					      &local_disc_list);
> +			list_add_tail(&rport->disc_list,
> &local_disc_list);
>  		}
>  	}
> 
>  
This looks good to me.
Reviewed-by: Laurence Oberman <loberman@redhat.com>



  reply	other threads:[~2026-10-23 14:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 14:00 [PATCH] nvme-fc: fix reference leak in nvme_fc_nvme_discovery_store() Martin George
2026-10-23 14:39 ` Laurence Oberman [this message]
2026-10-23 22:06 ` Keith Busch

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=cc8cee8648fd4a1614b71a49606c9520f87ae1e4.camel@redhat.com \
    --to=loberman@redhat.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martinus.gpy@gmail.com \
    --cc=sagi@grimberg.me \
    /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