scsi: lpfc: Fix error handling for mailboxes completed in MBX_POLL mode
authorJames Smart <jsmart2021@gmail.com>
Mon, 12 Apr 2021 01:31:17 +0000 (18:31 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 13 Apr 2021 05:39:13 +0000 (01:39 -0400)
commit304ee43238fed517faa123e034b593905b8679f8
treec1604734a084360c1b8fb80bb00bab52e8c6037d
parent4e76d4a9a226e3c7d453675f22359aba34e73ec4
scsi: lpfc: Fix error handling for mailboxes completed in MBX_POLL mode

In SLI-4, when performing a mailbox command with MBX_POLL, the driver uses
the BMBX register to send the command rather than the MQ. A flag is set
indicating the BMBX register is active and saves the mailbox job struct
(mboxq) in the mbox_active element of the adapter. The routine then waits
for completion or timeout. The mailbox job struct is not freed by the
routine. In cases of timeout, the adapter will be reset. The
lpfc_sli_mbox_sys_flush() routine will clean up the mbox in preparation for
the reset. It clears the BMBX active flag and marks the job structure as
MBX_NOT_FINISHED. But, it never frees the mboxq job structure. Expectation
in both normal completion and timeout cases is that the issuer of the mbx
command will free the structure.  Unfortunately, not all calling paths are
freeing the memory in cases of error.

All calling paths were looked at and updated, if missing, to free the mboxq
memory regardless of completion status.

Link: https://lore.kernel.org/r/20210412013127.2387-7-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_attr.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_sli.c