Skip to contentSkip to conversation

scsi: megaraid_sas: remove unnecessary 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: remove unnecessary kfree

When alloc ctrl mem fail, the reply_map will be free in megasas_free_ctrl_mem(), no need to free in megasas_alloc_ctrl_mem().

---
 drivers/scsi/megaraid/megaraid_sas_base.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +2 -6
index a3e117a..f6c37a9 100644
@@ -7153,22 +7153,18 @@ static int megasas_alloc_ctrl_mem(struct megasas_instance *instance)
 	switch (instance->adapter_type) {
 	case MFI_SERIES:
 		if (megasas_alloc_mfi_ctrl_mem(instance))
-			goto fail;
+			return -ENOMEM;
 		break;
 	case AERO_SERIES:
 	case VENTURA_SERIES:
 	case THUNDERBOLT_SERIES:
 	case INVADER_SERIES:
 		if (megasas_alloc_fusion_context(instance))
-			goto fail;
+			return -ENOMEM;
 		break;
 	}
 
 	return 0;
- fail:
-	kfree(instance->reply_map);
-	instance->reply_map = NULL;
-	return -ENOMEM;
 }
 
 /*
Signature · 1 line
1.8.3.1
author
#1 lore raw

Hi,

Gentle ping.

Quoted 37 lines · Guixin Liu

When alloc ctrl mem fail, the reply_map will be free in megasas_free_ctrl_mem(), no need to free in megasas_alloc_ctrl_mem().

---
  drivers/scsi/megaraid/megaraid_sas_base.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +2 -6
index a3e117a..f6c37a9 100644
@@ -7153,22 +7153,18 @@ static int megasas_alloc_ctrl_mem(struct megasas_instance *instance)
  	switch (instance->adapter_type) {
  	case MFI_SERIES:
  		if (megasas_alloc_mfi_ctrl_mem(instance))
-			goto fail;
+			return -ENOMEM;
  		break;
  	case AERO_SERIES:
  	case VENTURA_SERIES:
  	case THUNDERBOLT_SERIES:
  	case INVADER_SERIES:
  		if (megasas_alloc_fusion_context(instance))
-			goto fail;
+			return -ENOMEM;
  		break;
  	}
 
  	return 0;
- fail:
-	kfree(instance->reply_map);
-	instance->reply_map = NULL;
-	return -ENOMEM;
  }
 
  /*
#3 lore raw
In reply to Guixin Liu

Guixin,

Quoted 2 lines

When alloc ctrl mem fail, the reply_map will be free in megasas_free_ctrl_mem(), no need to free in megasas_alloc_ctrl_mem().

Applied to 5.20/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering