Skip to contentSkip to conversation

scsi: qla2xxx: fix memory leak if qlt_add_target fails

PATCH New Navid Emamdoost 1 participant 1 message Aug 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: qla2xxx: fix memory leak if qlt_add_target fails

In the implementation of qla2x00_probe_one() the allocated and initialized ha is leaked if it fails to add target via qlt_add_target(). Go to error handling path if qlt_add_target() fails.

---
 drivers/scsi/qla2xxx/qla_os.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_os.c +3 -1
index e92fad99338c..81a58ae54909 100644
@@ -3457,7 +3457,9 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 	    base_vha->host_no,
 	    ha->isp_ops->fw_version_str(base_vha, fw_str, sizeof(fw_str)));
 
-	qlt_add_target(ha, base_vha);
+	ret = qlt_add_target(ha, base_vha);
+	if (ret)
+		goto probe_failed;
 
 	clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags);
 
Signature · 1 line
2.17.1