]> www.infradead.org Git - users/jedix/linux-maple.git/commit
rtla: Fix segfault in save_trace_to_file call
authorTomas Glozar <tglozar@redhat.com>
Thu, 13 Mar 2025 14:10:34 +0000 (15:10 +0100)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 26 Mar 2025 14:35:20 +0000 (10:35 -0400)
commitc57c58a62e564c615520839742b28d315427a280
treeb5bacc617a07ec52fc77a81b824e18e7c3fa4ddb
parent814d051ebed40b27285ab3c5e2454bd01a0f9631
rtla: Fix segfault in save_trace_to_file call

Running rtla with exit on threshold, but without saving trace leads to a
segmenetation fault:

$ rtla timerlat hist -T 10
...
Max timerlat IRQ latency from idle: 4.29 us in cpu 0
Segmentation fault

This is caused by null pointer deference in the call of
save_trace_to_file, which attempts to dereference an uninitialized
osnoise_tool variable:

save_trace_to_file(record->trace.inst, params->trace_output);
                   ^ this is uninitialized if params->trace_output is
                     not set

Fix this by not attempting to dereference "record" if it is NULL and
passing NULL instead. As a safety measure, the first field is also
checked for NULL inside save_trace_to_file.

Cc: John Kacur <jkacur@redhat.com>
Cc: Luis Goncalves <lgoncalv@redhat.com>
Cc: Costa Shulyupin <costa.shul@redhat.com>
Link: https://lore.kernel.org/20250313141034.299117-1-tglozar@redhat.com
Fixes: dc4d4e7c72d1 ("rtla: Refactor save_trace_to_file")
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
tools/tracing/rtla/src/osnoise_hist.c
tools/tracing/rtla/src/osnoise_top.c
tools/tracing/rtla/src/timerlat_hist.c
tools/tracing/rtla/src/timerlat_top.c
tools/tracing/rtla/src/trace.c