Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit d1a2ef6

Browse files
Justin Teemartinkpetersen
authored andcommitted
scsi: lpfc: Fix kref imbalance on fabric ndlps from dev_loss_tmo handler
With a FLOGI outstanding and loss of physical link connection to the fabric for the duration of dev_loss_tmo, there is a fabric ndlp kref imbalance that decrements the kref and sets the NLP_IN_RECOV_POST_DEV_LOSS flag at the same time. The issue is that when the FLOGI completion routine executes, the fabric ndlp could already be freed because of the final kref put from the dev_loss_tmo handler. Fix by early returning before the ndlp kref put if the ndlp is deemed a candidate for NLP_IN_RECOV_POST_DEV_LOSS in the FLOGI completion routine. Signed-off-by: Justin Tee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 05ab4e7 commit d1a2ef6

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/scsi/lpfc/lpfc_hbadisc.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,9 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)
527527
* the following lpfc_nlp_put is necessary after fabric node is
528528
* recovered.
529529
*/
530+
spin_lock_irqsave(&ndlp->lock, iflags);
531+
ndlp->nlp_flag &= ~NLP_IN_DEV_LOSS;
532+
spin_unlock_irqrestore(&ndlp->lock, iflags);
530533
if (recovering) {
531534
lpfc_printf_vlog(vport, KERN_INFO,
532535
LOG_DISCOVERY | LOG_NODE,
@@ -539,6 +542,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)
539542
spin_lock_irqsave(&ndlp->lock, iflags);
540543
ndlp->save_flags |= NLP_IN_RECOV_POST_DEV_LOSS;
541544
spin_unlock_irqrestore(&ndlp->lock, iflags);
545+
return fcf_inuse;
542546
} else if (ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) {
543547
/* Fabric node fully recovered before this dev_loss_tmo
544548
* queue work is processed. Thus, ignore the
@@ -552,15 +556,9 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)
552556
ndlp->nlp_DID, kref_read(&ndlp->kref),
553557
ndlp, ndlp->nlp_flag,
554558
vport->port_state);
555-
spin_lock_irqsave(&ndlp->lock, iflags);
556-
ndlp->nlp_flag &= ~NLP_IN_DEV_LOSS;
557-
spin_unlock_irqrestore(&ndlp->lock, iflags);
558559
return fcf_inuse;
559560
}
560561

561-
spin_lock_irqsave(&ndlp->lock, iflags);
562-
ndlp->nlp_flag &= ~NLP_IN_DEV_LOSS;
563-
spin_unlock_irqrestore(&ndlp->lock, iflags);
564562
lpfc_nlp_put(ndlp);
565563
return fcf_inuse;
566564
}

0 commit comments

Comments
 (0)