]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: lpfc: Fix memory leak in lpfc_sli4_driver_resource_setup()
authorAbdun Nihaal <nihaal@cse.iitm.ac.in>
Tue, 7 Jul 2026 06:53:02 +0000 (12:23 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 9 Jul 2026 02:00:46 +0000 (22:00 -0400)
The memory allocated for mboxq using mempool_alloc() is not freed in
some of the early exit error paths. Fix that by moving the
mempool_free() call to an earlier point after last use.

Fixes: d79c9e9d4b3d ("scsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware.")
Cc: stable@vger.kernel.org
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Link: https://patch.msgid.link/20260707065304.949135-1-nihaal@cse.iitm.ac.in
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_init.c

index 82af59c913e9310baf48db81d926888f7668e3db..23355f12fbffa4006af3b3c0f65f7b15d290fd5a 100644 (file)
@@ -8189,6 +8189,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
                mempool_free(mboxq, phba->mbox_mem_pool);
                goto out_free_bsmbx;
        }
+       mempool_free(mboxq, phba->mbox_mem_pool);
 
        /*
         * 1 for cmd, 1 for rsp, NVME adds an extra one
@@ -8311,8 +8312,6 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
                goto out_free_sg_dma_buf;
        }
 
-       mempool_free(mboxq, phba->mbox_mem_pool);
-
        /* Verify OAS is supported */
        lpfc_sli4_oas_verify(phba);