[PATCH] scsi: mptfusion: Fix potential chain array leaks on attach failure

From: Guangshuo Li

Date: Fri Nov 13 2026 - 10:12:20 EST


initChainBuffers() can allocate some chain control arrays before IOC
bring-up fails. mpt_attach() then frees the adapter without releasing
those arrays.

Free the chain control arrays before freeing the adapter on this path.
This also handles partial allocation failures without invoking teardown
that requires a fully initialized adapter.

This issue was found by our static analysis tool under development.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/message/fusion/mptbase.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 3a431ffd3e2e..a0592404472c 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -2015,6 +2015,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
destroy_workqueue(ioc->reset_work_q);
ioc->reset_work_q = NULL;

+ kfree(ioc->ChainToChain);
+ kfree(ioc->RequestNB);
+ kfree(ioc->ReqToChain);
kfree(ioc);
return r;
}

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.43.0