[PATCH] scsi: arcmsr: Fix potential DMA leaks on XOR allocation failure
From: Guangshuo Li
Date: Tue Nov 17 2026 - 09:51:34 EST
XOR allocation failure is returned after the CCB pool has been allocated,
but probe skips pool cleanup on this error. Free the pool before returning
and handle a failed XOR header allocation without dereferencing it.
This issue was found by our static analysis tool under development.
Fixes: 14ef4b001ae7 ("scsi: arcmsr: Support new RAID controller ARC-1688")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/scsi/arcmsr/arcmsr_hba.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index 8aa948f06cac..52caa800397e 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -771,6 +771,10 @@ static int arcmsr_alloc_xor_buffer(struct AdapterControlBlock *acb)
(sizeof(struct XorHandle) * acb->xor_mega);
dma_coherent = dma_alloc_coherent(&pdev->dev, acb->init2cfg_size,
&dma_coherent_handle, GFP_KERNEL);
+ if (!dma_coherent) {
+ acb->xor_mega = 0;
+ return -ENOMEM;
+ }
acb->xorVirt = dma_coherent;
acb->xorPhys = dma_coherent_handle;
pXorPhys = (struct Xor_sg *)((unsigned long)dma_coherent +
@@ -895,8 +899,10 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb)
break;
}
if ((acb->firm_PicStatus >> 24) & 0x0f) {
- if (arcmsr_alloc_xor_buffer(acb))
+ if (arcmsr_alloc_xor_buffer(acb)) {
+ arcmsr_free_ccb_pool(acb);
return -ENOMEM;
+ }
}
return 0;
}
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4