scsi: lpfc: Fix mbuf pool resource detected as busy at driver unload
authorJames Smart <jsmart2021@gmail.com>
Sun, 11 Sep 2022 22:14:55 +0000 (15:14 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 16 Sep 2022 02:18:26 +0000 (22:18 -0400)
In a situation where the node state changes while a REG_LOGIN is in
progress, the LPFC_MBOXQ_t structure is cleared and reused for an
UNREG_LOGIN command to release RPI resources without first freeing the mbuf
pool resource allocated for REG_LOGIN.

Release mbuf pool resource prior to repurposing of the mailbox command
structure from REG_LOGIN to UNREG_LOGIN.

Link: https://lore.kernel.org/r/20220911221505.117655-4-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_sli.c

index 33373b20f819c37c7d48be632046e3965170bbdd..002794975cd9d63767dac3c9eee3e2d011276875 100644 (file)
@@ -2856,6 +2856,7 @@ void
 lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 {
        struct lpfc_vport  *vport = pmb->vport;
+       struct lpfc_dmabuf *mp;
        struct lpfc_nodelist *ndlp;
        struct Scsi_Host *shost;
        uint16_t rpi, vpi;
@@ -2868,6 +2869,12 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
        if (!(phba->pport->load_flag & FC_UNLOADING) &&
            pmb->u.mb.mbxCommand == MBX_REG_LOGIN64 &&
            !pmb->u.mb.mbxStatus) {
+               mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
+               if (mp) {
+                       pmb->ctx_buf = NULL;
+                       lpfc_mbuf_free(phba, mp->virt, mp->phys);
+                       kfree(mp);
+               }
                rpi = pmb->u.mb.un.varWords[0];
                vpi = pmb->u.mb.un.varRegLogin.vpi;
                if (phba->sli_rev == LPFC_SLI_REV4)