All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: lpfc: Fix ndlp reference leak in lpfc_nlp_reg_node()
@ 2026-09-17 14:45 Wentao Liang
  2026-09-17 14:57 ` sashiko-bot
  2026-09-17 18:24 ` Paul Ely
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-09-17 14:45 UTC (permalink / raw)
  To: James.Bottomley
  Cc: jsmart2021, justin.tee, linux-kernel, linux-scsi, martin.petersen,
	paul.ely, Wentao Liang, stable

In the NVMET case the driver takes a node reference in
lpfc_nlp_reg_node() because the target does not register rports, but
lpfc_nlp_unreg_node() only releases that reference when the
NVME_XPT_REGD flag is set, and the NVMET path never sets it, so the
reference is leaked until the node is torn down.

Set NVME_XPT_REGD when the reference is taken so the existing put in
lpfc_nlp_unreg_node() balances it.

Fixes: 0614568361b0 ("scsi: lpfc: Delay unregistering from transport until GIDFT or ADISC completes")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/scsi/lpfc/lpfc_hbadisc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index f3a85f6c796e..9e920eaff9ef 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -4664,9 +4664,15 @@ lpfc_nlp_reg_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
 			}
 		} else {
 			/* Just take an NDLP ref count since the
-			 * target does not register rports.
+			 * target does not register rports. Mark it as
+			 * an NVME transport ref so that
+			 * lpfc_nlp_unreg_node() releases it.
 			 */
 			lpfc_nlp_get(ndlp);
+
+			spin_lock_irqsave(&ndlp->lock, iflags);
+			ndlp->fc4_xpt_flags |= NVME_XPT_REGD;
+			spin_unlock_irqrestore(&ndlp->lock, iflags);
 		}
 	}
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-17 18:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-17 14:45 [PATCH] scsi: lpfc: Fix ndlp reference leak in lpfc_nlp_reg_node() Wentao Liang
2026-09-17 14:57 ` sashiko-bot
2026-09-17 18:24 ` Paul Ely

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.