tools lib traceevent: Add sanity check to is_timestamp_in_us()
authorTzvetomir Stoyanov <tstoyanov@vmware.com>
Wed, 28 Nov 2018 19:55:52 +0000 (14:55 -0500)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 17 Dec 2018 17:55:19 +0000 (14:55 -0300)
This patch adds a sanity check to is_timestamp_in_us() input parameter
trace_clock. It avoids a potential segfault in this function for the
case trace_clock is NULL.

Reported-by: Slavomir Kaslev <kaslevs@vmware.com>
Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20181128145552.68c4f87b@gandalf.local.home
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/traceevent/event-parse.c

index fbd6d68..2b5cb33 100644 (file)
@@ -5409,7 +5409,7 @@ void tep_event_info(struct trace_seq *s, struct tep_event_format *event,
 
 static bool is_timestamp_in_us(char *trace_clock, bool use_trace_clock)
 {
-       if (!use_trace_clock)
+       if (!trace_clock || !use_trace_clock)
                return true;
 
        if (!strcmp(trace_clock, "local") || !strcmp(trace_clock, "global")