]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: lpfc: Check devloss callbk done flag for potential stale NDLP ptrs
authorJustin Tee <justin.tee@broadcom.com>
Thu, 31 Oct 2024 22:32:10 +0000 (15:32 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sun, 3 Nov 2024 01:45:23 +0000 (21:45 -0400)
Should an rport remain in the NOTPRESENT state it is possible that
stgt_delete_work is scheduled after dev_loss_tmo_callbk.  In such cases,
dev_loss_tmo_callbk would have cleaned up the NDLP object resulting in
stale ndlp pointers in lpfc_terminate_rport_io().

Check for the DEVLOSS_CALLBK_DONE flag to know if dev_loss_tmo_callbk
has been called.  This is a more reliable way to avoid dereferencing
stale NDLP pointers.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20241031223219.152342-3-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_hbadisc.c

index 9241075f72fa4b5faf0ee848690c61a3c80270f5..a434faec3c92bd9d1df5bd5eff0f1a378982e4bc 100644 (file)
@@ -100,6 +100,12 @@ lpfc_rport_invalid(struct fc_rport *rport)
                return -EINVAL;
        }
 
+       if (rport->flags & FC_RPORT_DEVLOSS_CALLBK_DONE) {
+               pr_info("**** %s: devloss_callbk_done rport x%px SID x%x\n",
+                       __func__, rport, rport->scsi_target_id);
+               return -EINVAL;
+       }
+
        rdata = rport->dd_data;
        if (!rdata) {
                pr_err("**** %s: NULL dd_data on rport x%px SID x%x\n",