Skip to contentSkip to conversation

scsi: qla2xxx: fix a memleak in qla2x00_mem_alloc

PATCH New Zhipeng Lu 1 participant 1 message Dec 3, 2023

Subsystems (2)
lore
Share & tools
lore

Zhipeng Lu

author
#0 lore raw

PATCH 1/1 scsi: qla2xxx: fix a memleak in qla2x00_mem_alloc

When the dsd allocated in the for loop by kzalloc fails, it should gc all the resources allocated before, instead of just return a -ENOMEM.

According to the error-handling behavior of ha->dif_bundl_pool, the dsd's failure should free every resources after fail_dif_bundl_dma_pool, together with ha->dif_bundl_pool itself. So the error-handling should goes to label fail_dma_pool.

Fixes 50b812755e97 ("scsi: qla2xxx: Fix DMA error when the DIF sg buffer crosses 4GB boundary")
---
 drivers/scsi/qla2xxx/qla_os.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_os.c +1 -1
index 50db08265c51..bdd66f9e8850 100644
@@ -4252,7 +4252,7 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
 					ql_dbg_pci(ql_dbg_init, ha->pdev,
 					    0xe0ee, "%s: failed alloc dsd\n",
 					    __func__);
-					return -ENOMEM;
+					goto fail_dma_pool;
 				}
 				ha->dif_bundle_kallocs++;
 
Signature · 1 line
2.34.1