Skip to contentSkip to conversation

stm class: stm_heartbeat: fix error return code

PATCH New Wei Yongjun 1 participant 1 message Apr 28, 2020

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

PATCH 1/1 stm class: stm_heartbeat: fix error return code

Fix to return error code -ENOMEM from the error handling case instead of 0(ret can be overwritted to 0 in for loop).

---
 drivers/hwtracing/stm/heartbeat.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/hwtracing/stm/heartbeat.c +4 -2
index 3e7df1c0477f..81d7b21d31ec 100644
@@ -64,7 +64,7 @@ static void stm_heartbeat_unlink(struct stm_source_data *data)
 
 static int stm_heartbeat_init(void)
 {
-	int i, ret = -ENOMEM;
+	int i, ret;
 
 	if (nr_devs < 0 || nr_devs > STM_HEARTBEAT_MAX)
 		return -EINVAL;
@@ -72,8 +72,10 @@ static int stm_heartbeat_init(void)
 	for (i = 0; i < nr_devs; i++) {
 		stm_heartbeat[i].data.name =
 			kasprintf(GFP_KERNEL, "heartbeat.%d", i);
-		if (!stm_heartbeat[i].data.name)
+		if (!stm_heartbeat[i].data.name) {
+			ret = -ENOMEM;
 			goto fail_unregister;
+		}
 
 		stm_heartbeat[i].data.nr_chans	= 1;
 		stm_heartbeat[i].data.link	= stm_heartbeat_link;