mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: lpfc: Fix ndlp reference leak in lpfc_release_rpi()
@ 2026-09-17 14:47 Wentao Liang
  2026-09-17 19:35 ` Paul Ely
  0 siblings, 1 reply; 7+ messages in thread
From: Wentao Liang @ 2026-09-17 14:47 UTC (permalink / raw)
  To: James.Bottomley
  Cc: dick.kennedy, james.smart, justin.tee, linux-kernel, linux-scsi,
	martin.petersen, paul.ely, Wentao Liang, stable

lpfc_release_rpi() only drops the node reference and frees the mailbox
memory it took when lpfc_sli_issue_mbox() returns MBX_NOT_FINISHED.  The
SLI-4 issue path can also return -EIO without submitting the command, in
which case the completion handler never runs and both are leaked.

Clean up whenever the command was not handed to the port.

Fixes: 4430f7fd09ec ("scsi: lpfc: Rework locations of ndlp reference taking")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/scsi/lpfc/lpfc_nportdisc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index 9c449055a55e..055f44ec7b94 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -1142,7 +1142,13 @@ lpfc_release_rpi(struct lpfc_hba *phba, struct lpfc_vport *vport,
 				 ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag);
 
 		rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
-		if (rc == MBX_NOT_FINISHED) {
+
+		/* Only a queued or completed command is handed to the
+		 * port; other results, such as the -EIO returned by the
+		 * SLI-4 path when it cannot submit a non-polled command,
+		 * leave the mailbox and the node reference to the caller.
+		 */
+		if (rc != MBX_SUCCESS && rc != MBX_BUSY) {
 			lpfc_nlp_put(ndlp);
 			mempool_free(pmb, phba->mbox_mem_pool);
 		}
-- 
2.34.1


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

end of thread, other threads:[~2026-11-07 16:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 14:47 [PATCH] scsi: lpfc: Fix ndlp reference leak in lpfc_release_rpi() Wentao Liang
2026-09-17 19:35 ` Paul Ely
2026-10-06 21:21   ` Paul Ely
2026-11-07 15:17     ` Wentao Liang
2026-11-07 16:16     ` [PATCH v2 1/3] " Wentao Liang
2026-11-07 16:16       ` [PATCH v2 2/3] scsi: lpfc: Report bsg mailbox failures as an errno Wentao Liang
2026-11-07 16:16       ` [PATCH v2 3/3] scsi: lpfc: Return MBX status when a non-polled mbox cannot be issued Wentao Liang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®