6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andrey Misiurov The 6.1.y backport of upstream commit 1bd28625e25b ("scsi: lpfc: Fix memory leak in lpfc_sli4_driver_resource_setup()") added the new mempool_free() of mboxq in the wrong place. Upstream frees mboxq after the error handling of lpfc_get_sli4_parameters(). In 6.1.y the hunk landed before that call, right after the NVMET WWN loop: mempool_free(mboxq, phba->mbox_mem_pool); lpfc_nvme_mod_param_dep(phba); rc = lpfc_get_sli4_parameters(phba, mboxq); mbox_mem_pool is created a few lines earlier in the same function, so the pool is full and mempool_free() really kfree()s mboxq. lpfc_get_sli4_parameters() then builds and issues a mailbox command in freed memory. This happens on every SLI4 probe. Its error paths also free mboxq a second time. Move the mempool_free() to where upstream and the other stable trees have it. Fixes: 299f5baa1321 ("scsi: lpfc: Fix memory leak in lpfc_sli4_driver_resource_setup()") Signed-off-by: Andrey Misiurov Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 13ebbe4a71c47..fc5a640b7f742 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -8175,7 +8175,6 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) } } } - mempool_free(mboxq, phba->mbox_mem_pool); lpfc_nvme_mod_param_dep(phba); @@ -8209,6 +8208,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) goto out_free_bsmbx; } } + mempool_free(mboxq, phba->mbox_mem_pool); /* * 1 for cmd, 1 for rsp, NVME adds an extra one -- 2.53.0