Re: [PATCH] scsi: lpfc: Fix memory leak in lpfc_sli4_driver_resource_setup()
From: Markus Elfring
Date: Fri Jul 10 2026 - 14:00:51 EST
> 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.
…
> +++ b/drivers/scsi/lpfc/lpfc_init.c
> @@ -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
How do you think about to move the mempool_free() call directly behind
the statement “rc = lpfc_get_sli4_parameters(phba, mboxq);”?
https://elixir.bootlin.com/linux/v7.2-rc2/source/drivers/scsi/lpfc/lpfc_init.c#L8180-L8191
Regards,
Markus