[PATCH] scsi: lpfc: Fix ndlp reference leak in lpfc_nlp_reg_node()
From: Wentao Liang
Date: Thu Sep 17 2026 - 12:25:05 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
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