scsi: lpfc: Fix crash involving race between FLOGI timeout and devloss handler
authorJustin Tee <justin.tee@broadcom.com>
Wed, 16 Nov 2022 01:19:19 +0000 (17:19 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 17 Nov 2022 18:18:42 +0000 (18:18 +0000)
commit97f256913c5d8a633efe4f11d4ed2d6a3ea42635
tree42d344549ad76450a020f05717bce028242986f2
parentd99af587d59ca39747b4328dad0b193655835c90
scsi: lpfc: Fix crash involving race between FLOGI timeout and devloss handler

When a FLOGI completes with a sequence timeout error, a freed kref ptr
dereference crash can occur due to a timing race involving ndlp referencing
in lpfc_dev_loss_tmo_callbk.

Fix by ensuring the driver accounts for an outstanding FLOGI when dev_loss
is active.  Also, don't remove the HBA_FLOGI_OUTSTANDING flag when the
FLOGI is retried to allow the driver to handle the reference counts
correctly in lpfc_dev_loss_tmo_handler.

Reported-by: Dietmar Hahn <dietmar.hahn@fujitsu.com>
Tested-by: Dietmar Hahn <dietmar.hahn@fujitsu.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20221116011921.105995-5-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_els.c
drivers/scsi/lpfc/lpfc_hbadisc.c