* [PATCH -next] stm class: stm_heartbeat: fix error return code
@ 2020-04-28 13:48 Wei Yongjun
0 siblings, 0 replies; only message in thread
From: Wei Yongjun @ 2020-04-28 13:48 UTC (permalink / raw)
To: Alexander Shishkin, Maxime Coquelin, Alexandre Torgue
Cc: Wei Yongjun, linux-stm32, linux-arm-kernel, linux-kernel,
kernel-janitors
Fix to return error code -ENOMEM from the error handling case instead
of 0(ret can be overwritted to 0 in for loop).
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
drivers/hwtracing/stm/heartbeat.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/hwtracing/stm/heartbeat.c b/drivers/hwtracing/stm/heartbeat.c
index 3e7df1c0477f..81d7b21d31ec 100644
--- a/drivers/hwtracing/stm/heartbeat.c
+++ b/drivers/hwtracing/stm/heartbeat.c
@@ -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;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-28 13:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28 13:48 [PATCH -next] stm class: stm_heartbeat: fix error return code Wei Yongjun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).