Skip to contentSkip to conversation

scsi: megaraid_sas: fix double kfree

PATCH Applied Guixin Liu 3 participants 4 messages Aug 2, 2022 – Aug 12, 2022

Subsystems (2)
lore
Share & tools
lore

Guixin Liu

author
#0 lore raw

PATCH 1/1 scsi: megaraid_sas: fix double kfree

When alloc log_to_span fail, call kfree(instance->ctrl_context) first, then jump to megasas_free_ctrl_mem() in megasas_init_fw(), call kfree(instance->ctrl_context) second.

---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 -
 1 file changed, 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_fusion.c +0 -1
index 5b5885d..3e9b2b0 100644
@@ -5311,7 +5311,6 @@ void megasas_fusion_ocr_wq(struct work_struct *work)
 		if (!fusion->log_to_span) {
 			dev_err(&instance->pdev->dev, "Failed from %s %d\n",
 				__func__, __LINE__);
-			kfree(instance->ctrl_context);
 			return -ENOMEM;
 		}
 	}
Signature · 1 line
1.8.3.1
author
#1 lore raw

Hi,

Gentle ping.

Quoted 21 lines · Guixin Liu

When alloc log_to_span fail, call kfree(instance->ctrl_context) first, then jump to megasas_free_ctrl_mem() in megasas_init_fw(), call kfree(instance->ctrl_context) second.

---
  drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 -
  1 file changed, 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_fusion.c +0 -1
index 5b5885d..3e9b2b0 100644
@@ -5311,7 +5311,6 @@ void megasas_fusion_ocr_wq(struct work_struct *work)
  		if (!fusion->log_to_span) {
  			dev_err(&instance->pdev->dev, "Failed from %s %d\n",
  				__func__, __LINE__);
-			kfree(instance->ctrl_context);
  			return -ENOMEM;
  		}
  	}
#3 lore raw
In reply to Guixin Liu

Guixin,

Quoted 3 lines

When alloc log_to_span fail, call kfree(instance->ctrl_context) first, then jump to megasas_free_ctrl_mem() in megasas_init_fw(), call kfree(instance->ctrl_context) second.

Applied to 5.20/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering