Daniel Wagner 45df21
From: James Smart <jsmart2021@gmail.com>
Daniel Wagner 45df21
Date: Fri, 14 May 2021 12:55:56 -0700
Daniel Wagner 45df21
Subject: scsi: lpfc: Fix crash when lpfc_sli4_hba_setup() fails to initialize
Daniel Wagner 45df21
 the SGLs
Michal Kubecek 9a3a83
Patch-mainline: v5.14-rc1
Daniel Wagner 45df21
Git-commit: 5aa615d195f1e142c662cb2253f057c9baec7531
Daniel Wagner 45df21
References: bsc#1186451
Daniel Wagner 45df21
Daniel Wagner 45df21
The driver is encountering a crash in lpfc_free_iocb_list() while
Daniel Wagner 45df21
performing initial attachment.
Daniel Wagner 45df21
Daniel Wagner 45df21
Code review found this to be an errant failure path that was taken, jumping
Daniel Wagner 45df21
to a tag that then referenced structures that were uninitialized.
Daniel Wagner 45df21
Daniel Wagner 45df21
Fix the failure path.
Daniel Wagner 45df21
Daniel Wagner 45df21
Link: https://lore.kernel.org/r/20210514195559.119853-9-jsmart2021@gmail.com
Daniel Wagner 45df21
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Daniel Wagner 45df21
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Daniel Wagner 45df21
Signed-off-by: James Smart <jsmart2021@gmail.com>
Daniel Wagner 45df21
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Daniel Wagner 45df21
Acked-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner 45df21
---
Daniel Wagner 45df21
 drivers/scsi/lpfc/lpfc_sli.c |    5 +++--
Daniel Wagner 45df21
 1 file changed, 3 insertions(+), 2 deletions(-)
Daniel Wagner 45df21
Daniel Wagner 45df21
--- a/drivers/scsi/lpfc/lpfc_sli.c
Daniel Wagner 45df21
+++ b/drivers/scsi/lpfc/lpfc_sli.c
Daniel Wagner 45df21
@@ -7964,7 +7964,7 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phb
Daniel Wagner 45df21
 				"0393 Error %d during rpi post operation\n",
Daniel Wagner 45df21
 				rc);
Daniel Wagner 45df21
 		rc = -ENODEV;
Daniel Wagner 45df21
-		goto out_destroy_queue;
Daniel Wagner 45df21
+		goto out_free_iocblist;
Daniel Wagner 45df21
 	}
Daniel Wagner 45df21
 	lpfc_sli4_node_prep(phba);
Daniel Wagner 45df21
 
Daniel Wagner 45df21
@@ -8130,8 +8130,9 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phb
Daniel Wagner 45df21
 out_unset_queue:
Daniel Wagner 45df21
 	/* Unset all the queues set up in this routine when error out */
Daniel Wagner 45df21
 	lpfc_sli4_queue_unset(phba);
Daniel Wagner 45df21
-out_destroy_queue:
Daniel Wagner 45df21
+out_free_iocblist:
Daniel Wagner 45df21
 	lpfc_free_iocb_list(phba);
Daniel Wagner 45df21
+out_destroy_queue:
Daniel Wagner 45df21
 	lpfc_sli4_queue_destroy(phba);
Daniel Wagner 45df21
 out_stop_timers:
Daniel Wagner 45df21
 	lpfc_stop_hba_timers(phba);