Skip to content

Commit 927633a

Browse files
Wang Huigregkh
authored andcommitted
stm class: Fix module init return on allocation failure
In stm_heartbeat_init(): return value gets reset after the first iteration by stm_source_register_device(), so allocation failures after that will, after a clean up, return success. Fix that. Fixes: 1192918 ("stm class: Add heartbeat stm source device") Reported-by: Hulk Robot <[email protected]> Signed-off-by: Wang Hui <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 02039b1 commit 927633a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/hwtracing/stm/heartbeat.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,18 @@ static void stm_heartbeat_unlink(struct stm_source_data *data)
6464

6565
static int stm_heartbeat_init(void)
6666
{
67-
int i, ret = -ENOMEM;
67+
int i, ret;
6868

6969
if (nr_devs < 0 || nr_devs > STM_HEARTBEAT_MAX)
7070
return -EINVAL;
7171

7272
for (i = 0; i < nr_devs; i++) {
7373
stm_heartbeat[i].data.name =
7474
kasprintf(GFP_KERNEL, "heartbeat.%d", i);
75-
if (!stm_heartbeat[i].data.name)
75+
if (!stm_heartbeat[i].data.name) {
76+
ret = -ENOMEM;
7677
goto fail_unregister;
78+
}
7779

7880
stm_heartbeat[i].data.nr_chans = 1;
7981
stm_heartbeat[i].data.link = stm_heartbeat_link;

0 commit comments

Comments
 (0)