diff mbox series

scsi: qla2xxx: fix a double free in qla2x00_probe_one

Message ID 20231220034448.13249-1-dinghao.liu@zju.edu.cn (mailing list archive)
State New, archived
Headers show
Series scsi: qla2xxx: fix a double free in qla2x00_probe_one | expand

Commit Message

Dinghao Liu Dec. 20, 2023, 3:44 a.m. UTC
When qla2x00_mem_alloc() fails, it has cleaned up resources
in its error paths. However, qla2x00_probe_one() calls
qla2x00_mem_free() on failure of qla2x00_mem_alloc() and
tries to free the resources again, which may casue a
double-free.

Fixes: d64d6c5671db ("scsi: qla2xxx: Fix NULL pointer crash due to probe failure")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/scsi/qla2xxx/qla_os.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 03348f605c2e..0d8d6c814723 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3249,7 +3249,7 @@  qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 		ql_log_pci(ql_log_fatal, pdev, 0x0031,
 		    "Failed to allocate memory for adapter, aborting.\n");
 
-		goto probe_hw_failed;
+		goto mem_alloc_failed;
 	}
 
 	req->max_q_depth = MAX_Q_DEPTH;
@@ -3660,6 +3660,8 @@  qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 
 probe_hw_failed:
 	qla2x00_mem_free(ha);
+
+mem_alloc_failed:
 	qla2x00_free_req_que(ha, req);
 	qla2x00_free_rsp_que(ha, rsp);
 	qla2x00_clear_drv_active(ha);