Skip to contentSkip to conversation

add missing calls to kfree

PATCH New Quentin Lambert 1 participant 3 messages Aug 12, 2016

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

v2 cover add missing calls to kfree

The first patch is a style fix, the second add calls to kfree.
The reason for me thinking that they are necessary is that every other branches leading to an error return are jumping to the same destination.

v2: add a commit message to the first patch

---
 drivers/staging/rts5208/ms.c |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

---

#1 lore raw

PATCH v2 1/2 staging: rts5208/ms.c: change the label name to respect the coding style

This patch changes label names using camel case to snake case as well as giving a new name representing what will be done after the label.

---
v2: add a commit message

 drivers/staging/rts5208/ms.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/rts5208/ms.c +6 -6
@@ -4313,7 +4313,7 @@ int mg_get_local_EKB(struct scsi_cmnd *s
 	if (retval != STATUS_SUCCESS) {
 		set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
 		rtsx_trace(chip);
-		goto GetEKBFinish;
+		goto free_buffer;
 	}
 
 	retval = ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA,
@@ -4322,7 +4322,7 @@ int mg_get_local_EKB(struct scsi_cmnd *s
 		set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
 		rtsx_clear_ms_error(chip);
 		rtsx_trace(chip);
-		goto GetEKBFinish;
+		goto free_buffer;
 	}
 	if (check_ms_err(chip)) {
 		set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
@@ -4334,7 +4334,7 @@ int mg_get_local_EKB(struct scsi_cmnd *s
 	bufflen = min_t(int, 1052, scsi_bufflen(srb));
 	rtsx_stor_set_xfer_buf(buf, bufflen, srb);
 
-GetEKBFinish:
+free_buffer:
 	kfree(buf);
 	return retval;
 }
@@ -4566,7 +4566,7 @@ int mg_get_ICV(struct scsi_cmnd *srb, st
 	if (retval != STATUS_SUCCESS) {
 		set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
 		rtsx_trace(chip);
-		goto GetICVFinish;
+		goto free_buffer;
 	}
 
 	retval = ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA,
@@ -4575,7 +4575,7 @@ int mg_get_ICV(struct scsi_cmnd *srb, st
 		set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
 		rtsx_clear_ms_error(chip);
 		rtsx_trace(chip);
-		goto GetICVFinish;
+		goto free_buffer;
 	}
 	if (check_ms_err(chip)) {
 		set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
@@ -4587,7 +4587,7 @@ int mg_get_ICV(struct scsi_cmnd *srb, st
 	bufflen = min_t(int, 1028, scsi_bufflen(srb));
 	rtsx_stor_set_xfer_buf(buf, bufflen, srb);
 
-GetICVFinish:
+free_buffer:
 	kfree(buf);
 	return retval;
 }
#2 lore raw

PATCH v2 2/2 staging: rts5208/ms.c: add missing releases in mg_get_local_EKB and mg_get_ICV

In reply to Quentin Lambert

mg_get_local_EKB and mg_get_ICV used to return with an error code before releasing all resources. This patch add a jump to the appropriate label ensuring that the resources are properly released before returning.

This issue was found with Hector.

---
 drivers/staging/rts5208/ms.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/rts5208/ms.c +4 -2
@@ -4328,7 +4328,8 @@ int mg_get_local_EKB(struct scsi_cmnd *s
 		set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
 		rtsx_clear_ms_error(chip);
 		rtsx_trace(chip);
-		return STATUS_FAIL;
+		retval = STATUS_FAIL;
+		goto free_buffer;
 	}
 
 	bufflen = min_t(int, 1052, scsi_bufflen(srb));
@@ -4581,7 +4582,8 @@ int mg_get_ICV(struct scsi_cmnd *srb, st
 		set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
 		rtsx_clear_ms_error(chip);
 		rtsx_trace(chip);
-		return STATUS_FAIL;
+		retval = STATUS_FAIL;
+		goto free_buffer;
 	}
 
 	bufflen = min_t(int, 1028, scsi_bufflen(srb));