From: sashiko-bot@kernel.org
To: "Nguyen Duy Nhat Anh" <neganhat@gmail.com>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvmet-fc: skip port entry rebinding if already bound to a target port
Date: Fri, 16 Oct 2026 15:53:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-174586@kernel.org> (raw)
In-Reply-To: <20261016154807.9544-1-neganhat@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] nvme-fc: refcount leak of tgtport in nvmet_fc_portentry_rebind_tgt()
--
commit 3f22f46c30c7c3045ffe22fb5654e54b5aabd759
Author: Nguyen Duy Nhat Anh <neganhat@gmail.com>
nvmet-fc: skip port entry rebinding if already bound to a target port
In nvmet_fc_portentry_rebind_tgt(), nvmet_fc_tgtlock serializes access to
nvmet_fc_portentry_list, but does not prevent multiple concurrent or
duplicate target port registrations from attempting to rebind to an
already-assigned port entry. This fix checks if pe->tgtport is already
set before rebinding to prevent clobbering existing bindings.
Closes: https://syzkaller.appspot.com/bug?extid=be62d4b375542ecebd17
> Fix this by checking if pe->tgtport is already set before acquiring a
> reference count and rebinding. If it is bound, skip the entry to prevent
> clobbering existing bindings.
[Severity: Medium]
The commit message states the check is performed before acquiring the
reference count, but the diff below shows the check occurring after
nvmet_fc_tgtport_get() is called.
> diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
> index eecdffefa24fa..ac3194497a1e0 100644
> --- a/drivers/nvme/target/fc.c
> +++ b/drivers/nvme/target/fc.c
> @@ -1324,7 +1324,9 @@ nvmet_fc_portentry_rebind_tgt(struct nvmet_fc_tgtport *tgtport)
> if (!nvmet_fc_tgtport_get(tgtport))
> continue;
>
> - WARN_ON(pe->tgtport);
> + if (pe->tgtport)
> + continue;
> +
[Severity: Medium]
Does this code leak the tgtport reference?
If pe->tgtport is already set, this continue path skips the entry but doesn't
drop the reference acquired by nvmet_fc_tgtport_get(tgtport) just above it.
Should the check for pe->tgtport be moved before the nvmet_fc_tgtport_get()
call, or should it call nvmet_fc_tgtport_put() before continuing?
> tgtport->pe = pe;
> pe->tgtport = tgtport;
> break;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261016154807.9544-1-neganhat@gmail.com?part=1
next prev parent reply other threads:[~2026-10-16 15:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 15:48 [PATCH] nvmet-fc: skip port entry rebinding if already bound to a target port Nguyen Duy Nhat Anh
2026-10-16 15:53 ` sashiko-bot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-10-16 15:54 Nguyen Duy Nhat Anh
2026-10-16 15:58 ` sashiko-bot
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=sashiko-outbox-174586@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=neganhat@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.