Skip to contentSkip to conversation

tools/lib/traceevent: Add sanity check to is_timestamp_in_us()

PATCH New Steven Rostedt 2 participants 3 messages Nov 28, 2018 – Dec 18, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/lib/traceevent: Add sanity check to is_timestamp_in_us()

From: Tzvetomir Stoyanov <[email protected]>

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.

---
 tools/lib/traceevent/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +1 -1
index 3692f29fee46..c383305510b4 100644
@@ -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")
Signature · 1 line
2.19.1
#1 lore raw

[tip:perf/core] tools lib traceevent: Add sanity check to is_timestamp_in_us()

tools lib traceevent: Add sanity check to is_timestamp_in_us()
Commit-ID:  51d0337d01985d0cccb6e41f976cc0dbe921fd84
Gitweb:     https://git.kernel.org/tip/51d0337d01985d0cccb6e41f976cc0dbe921fd84
Author:     Tzvetomir Stoyanov <[email protected]>
AuthorDate: Wed, 28 Nov 2018 14:55:52 -0500
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 29 Nov 2018 20:42:50 -0300

tools lib traceevent: Add sanity check to is_timestamp_in_us()

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.

---
 tools/lib/traceevent/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +1 -1
index fbd6d6813fab..2b5cb33046ce 100644
@@ -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")
#2 lore raw

[tip:perf/core] tools lib traceevent: Add sanity check to is_timestamp_in_us()

In reply to Steven Rostedt
tools lib traceevent: Add sanity check to is_timestamp_in_us()
Commit-ID:  44e92f8389b2242efde77d5321ffa88decd47df6
Gitweb:     https://git.kernel.org/tip/44e92f8389b2242efde77d5321ffa88decd47df6
Author:     Tzvetomir Stoyanov <[email protected]>
AuthorDate: Wed, 28 Nov 2018 14:55:52 -0500
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 17 Dec 2018 14:55:19 -0300

tools lib traceevent: Add sanity check to is_timestamp_in_us()

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.

---
 tools/lib/traceevent/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +1 -1
index fbd6d6813fab..2b5cb33046ce 100644
@@ -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")