| From 151897799c8825006762417ddee2990f11e994e5 Mon Sep 17 00:00:00 2001 |
| From: James Smart <jsmart2021@gmail.com> |
| Date: Sun, 22 Mar 2020 11:12:57 -0700 |
| Subject: [PATCH] scsi: lpfc: Fix crash after handling a pci error |
| |
| commit 4cd70891308dfb875ef31060c4a4aa8872630a2e upstream. |
| |
| Injecting EEH on a 32GB card is causing kernel oops |
| |
| The pci error handler is doing an IO flush and the offline code is also |
| doing an IO flush. When the 1st flush is complete the hdwq is destroyed |
| (freed), yet the second flush accesses the hdwq and crashes. |
| |
| Added a check in lpfc_sli4_fush_io_rings to check both the HBA_IOQ_FLUSH |
| flag and the hdwq pointer to see if it is already set and not already |
| freed. |
| |
| Link: https://lore.kernel.org/r/20200322181304.37655-6-jsmart2021@gmail.com |
| Signed-off-by: James Smart <jsmart2021@gmail.com> |
| Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com> |
| Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> |
| [PG: fcp was renamed out of existence in upstream c00f62e6c546.] |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c |
| index 2d47b2978f6d..6e97d85c698d 100644 |
| --- a/drivers/scsi/lpfc/lpfc_sli.c |
| +++ b/drivers/scsi/lpfc/lpfc_sli.c |
| @@ -3994,6 +3994,11 @@ lpfc_sli_flush_fcp_rings(struct lpfc_hba *phba) |
| struct lpfc_iocbq *piocb, *next_iocb; |
| |
| spin_lock_irq(&phba->hbalock); |
| + if (phba->hba_flag & HBA_FCP_IOQ_FLUSH || |
| + !phba->sli4_hba.hdwq) { |
| + spin_unlock_irq(&phba->hbalock); |
| + return; |
| + } |
| /* Indicate the I/O queues are flushed */ |
| phba->hba_flag |= HBA_FCP_IOQ_FLUSH; |
| spin_unlock_irq(&phba->hbalock); |
| -- |
| 2.7.4 |
| |