Skip to content

Commit 4bbf59a

Browse files
Daniel Bristot de Oliveirarostedt
authored andcommitted
rtla: Fix segmentation fault when failing to enable -t
rtla osnoise and timerlat are causing a segmentation fault when running with the --trace option on a kernel that does not support multiple instances. For example: [root@f34 rtla]# rtla osnoise top -t failed to enable the tracer osnoise Could not enable osnoiser tracer for tracing Failed to enable the trace instance Segmentation fault (core dumped) This error happens because the exit code of the tools is trying to destroy the trace instance that failed to be created. Make osnoise_destroy_tool() aware of possible NULL osnoise_tool *, and do not attempt to destroy it. This also simplifies the exit code. Link: https://lkml.kernel.org/r/5660a2b6bf66c2655842360f2d7f6b48db5dba23.1644327249.git.bristot@kernel.org Suggested-by: Steven Rostedt <[email protected]> Fixes: 1eceb2f ("rtla/osnoise: Add osnoise top mode") Fixes: 829a6c0 ("rtla/osnoise: Add the hist mode") Fixes: a828cd1 ("rtla: Add timerlat tool and timelart top mode") Fixes: 1eeb632 ("rtla/timerlat: Add timerlat hist mode") Signed-off-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 1a62290 commit 4bbf59a

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

tools/tracing/rtla/src/osnoise.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,9 @@ void osnoise_put_context(struct osnoise_context *context)
750750
*/
751751
void osnoise_destroy_tool(struct osnoise_tool *top)
752752
{
753+
if (!top)
754+
return;
755+
753756
trace_instance_destroy(&top->trace);
754757

755758
if (top->context)

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,9 @@ osnoise_hist_set_signals(struct osnoise_hist_params *params)
701701
int osnoise_hist_main(int argc, char *argv[])
702702
{
703703
struct osnoise_hist_params *params;
704+
struct osnoise_tool *record = NULL;
705+
struct osnoise_tool *tool = NULL;
704706
struct trace_instance *trace;
705-
struct osnoise_tool *record;
706-
struct osnoise_tool *tool;
707707
int return_value = 1;
708708
int retval;
709709

@@ -792,9 +792,8 @@ int osnoise_hist_main(int argc, char *argv[])
792792
out_hist:
793793
osnoise_free_histogram(tool->data);
794794
out_destroy:
795+
osnoise_destroy_tool(record);
795796
osnoise_destroy_tool(tool);
796-
if (params->trace_output)
797-
osnoise_destroy_tool(record);
798797
free(params);
799798
out_exit:
800799
exit(return_value);

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,9 @@ static void osnoise_top_set_signals(struct osnoise_top_params *params)
483483
int osnoise_top_main(int argc, char **argv)
484484
{
485485
struct osnoise_top_params *params;
486+
struct osnoise_tool *record = NULL;
487+
struct osnoise_tool *tool = NULL;
486488
struct trace_instance *trace;
487-
struct osnoise_tool *record;
488-
struct osnoise_tool *tool;
489489
int return_value = 1;
490490
int retval;
491491

@@ -571,9 +571,8 @@ int osnoise_top_main(int argc, char **argv)
571571

572572
out_top:
573573
osnoise_free_top(tool->data);
574+
osnoise_destroy_tool(record);
574575
osnoise_destroy_tool(tool);
575-
if (params->trace_output)
576-
osnoise_destroy_tool(record);
577576
out_exit:
578577
exit(return_value);
579578
}

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,9 @@ timerlat_hist_set_signals(struct timerlat_hist_params *params)
729729
int timerlat_hist_main(int argc, char *argv[])
730730
{
731731
struct timerlat_hist_params *params;
732+
struct osnoise_tool *record = NULL;
733+
struct osnoise_tool *tool = NULL;
732734
struct trace_instance *trace;
733-
struct osnoise_tool *record;
734-
struct osnoise_tool *tool;
735735
int return_value = 1;
736736
int retval;
737737

@@ -813,9 +813,8 @@ int timerlat_hist_main(int argc, char *argv[])
813813

814814
out_hist:
815815
timerlat_free_histogram(tool->data);
816+
osnoise_destroy_tool(record);
816817
osnoise_destroy_tool(tool);
817-
if (params->trace_output)
818-
osnoise_destroy_tool(record);
819818
free(params);
820819
out_exit:
821820
exit(return_value);

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,9 @@ timerlat_top_set_signals(struct timerlat_top_params *params)
521521
int timerlat_top_main(int argc, char *argv[])
522522
{
523523
struct timerlat_top_params *params;
524+
struct osnoise_tool *record = NULL;
525+
struct osnoise_tool *top = NULL;
524526
struct trace_instance *trace;
525-
struct osnoise_tool *record;
526-
struct osnoise_tool *top;
527527
int return_value = 1;
528528
int retval;
529529

@@ -609,9 +609,8 @@ int timerlat_top_main(int argc, char *argv[])
609609

610610
out_top:
611611
timerlat_free_top(top->data);
612+
osnoise_destroy_tool(record);
612613
osnoise_destroy_tool(top);
613-
if (params->trace_output)
614-
osnoise_destroy_tool(record);
615614
free(params);
616615
out_exit:
617616
exit(return_value);

0 commit comments

Comments
 (0)