[PATCH] scsi: mpt3sas: Fix memory leak in _base_enable_msix()

Zilin Guan posted 1 patch 1 month, 1 week ago
drivers/scsi/mpt3sas/mpt3sas_base.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] scsi: mpt3sas: Fix memory leak in _base_enable_msix()
Posted by Zilin Guan 1 month, 1 week ago
In _base_enable_msix(), if _base_alloc_irq_vectors() fails, the function
jumps to the try_ioapic label without freeing the allocated
ioc->io_uring_poll_queues, leading to a memory leak.

Fix this by freeing ioc->io_uring_poll_queues before jumping to
try_ioapic.

Fixes: 1d55abc0e98a ("scsi: mpt3sas: switch to pci_alloc_irq_vectors")
Co-developed-by: Jianhao Xu <jianhao.xu@seu.edu.cn>
Signed-off-by: Jianhao Xu <jianhao.xu@seu.edu.cn>
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 0d652db8fe24..2b7f823fb4cb 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -3507,6 +3507,7 @@ _base_enable_msix(struct MPT3SAS_ADAPTER *ioc)
 	r = _base_alloc_irq_vectors(ioc);
 	if (r < 0) {
 		ioc_info(ioc, "pci_alloc_irq_vectors failed (r=%d) !!!\n", r);
+		kfree(ioc->io_uring_poll_queues);
 		goto try_ioapic;
 	}
 
-- 
2.34.1