[PATCH 1/3] scsi: lpfc: Fix memory leak in lpfc_config_port_post()
From: Zilin Guan
Date: Mon Dec 29 2025 - 02:16:32 EST
In lpfc_config_port_post(), pmb is allocated via mempool_alloc() but
is not freed when lpfc_readl() fails.
Fix this by adding mempool_free() in the error path.
Fixes: 9940b97bb30d ("[SCSI] lpfc 8.3.22: Add support for PCI Adapter Failure")
Co-developed-by: Jianhao Xu <jianhao.xu@xxxxxxxxxx>
Signed-off-by: Jianhao Xu <jianhao.xu@xxxxxxxxxx>
Signed-off-by: Zilin Guan <zilin@xxxxxxxxxx>
---
drivers/scsi/lpfc/lpfc_init.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index b1460b16dd91..bc2e55f6a50f 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -572,6 +572,7 @@ lpfc_config_port_post(struct lpfc_hba *phba)
/* Enable appropriate host interrupts */
if (lpfc_readl(phba->HCregaddr, &status)) {
spin_unlock_irq(&phba->hbalock);
+ mempool_free(pmb, phba->mbox_mem_pool);
return -EIO;
}
status |= HC_MBINT_ENA | HC_ERINT_ENA | HC_LAINT_ENA;
--
2.34.1