Skip to content

Commit d847188

Browse files
walaclenticularis39
authored andcommitted
rtla: Handle pthread_create() failure properly
Add proper error handling when pthread_create() fails to create the timerlat user-space dispatcher thread. Previously, the code only logged an error message but continued execution, which could lead to undefined behavior when the tool later expects the thread to be running. When pthread_create() returns an error, the function now jumps to the out_trace error path to properly clean up resources and exit. This ensures consistent error handling and prevents the tool from running in an invalid state without the required user-space thread. Signed-off-by: Wander Lairson Costa <wander@redhat.com> Link: https://lore.kernel.org/r/20260309195040.1019085-10-wander@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
1 parent d651542 commit d847188

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

tools/tracing/rtla/src/common.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,10 @@ int run_tool(struct tool_ops *ops, int argc, char *argv[])
336336
params->user.cgroup_name = params->cgroup_name;
337337

338338
retval = pthread_create(&user_thread, NULL, timerlat_u_dispatcher, &params->user);
339-
if (retval)
339+
if (retval) {
340340
err_msg("Error creating timerlat user-space threads\n");
341+
goto out_trace;
342+
}
341343
}
342344

343345
retval = ops->enable(tool);

0 commit comments

Comments
 (0)