diff mbox series

tools/lib/traceevent: Sanity check of is_timestamp_in_us()

Message ID 20181128144038.21915-1-tstoyanov@vmware.com (mailing list archive)
State Accepted
Headers show
Series tools/lib/traceevent: Sanity check of is_timestamp_in_us() | expand

Commit Message

Tzvetomir Stoyanov Nov. 28, 2018, 2:40 p.m. UTC
This patch adds a sanity check of is_timestamp_in_us() input
parameter trace_clock. It avoids a potential segfailt in this
function in case trace_clock is NULL.

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
---
 tools/lib/traceevent/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steven Rostedt Nov. 28, 2018, 2:44 p.m. UTC | #1
On Wed, 28 Nov 2018 14:40:49 +0000
Tzvetomir Stoyanov <tstoyanov@vmware.com> wrote:

> This patch adds a sanity check of is_timestamp_in_us() input
> parameter trace_clock. It avoids a potential segfailt in this
> function in case trace_clock is NULL.
> 
> Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>

Thanks Tzvetomir!

I'm going to add a:

 Reported-by: Slavomir Kaslev <kaslevs@vmware.com>

to this patch.

-- Steve

> ---
>  tools/lib/traceevent/event-parse.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index 854b68ef2e4e..12449c308853 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -5454,7 +5454,7 @@ void tep_event_info(struct trace_seq *s, struct tep_event *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")
Steven Rostedt Nov. 30, 2018, 4:27 p.m. UTC | #2
On Wed, 28 Nov 2018 14:40:49 +0000
Tzvetomir Stoyanov <tstoyanov@vmware.com> wrote:

> This patch adds a sanity check of is_timestamp_in_us() input
> parameter trace_clock. It avoids a potential segfailt in this
> function in case trace_clock is NULL.

FYI, I applied this to trace-cmd as well.

-- Steve

> 
> Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
> ---
>  tools/lib/traceevent/event-parse.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index 854b68ef2e4e..12449c308853 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -5454,7 +5454,7 @@ void tep_event_info(struct trace_seq *s, struct tep_event *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")
diff mbox series

Patch

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 854b68ef2e4e..12449c308853 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -5454,7 +5454,7 @@  void tep_event_info(struct trace_seq *s, struct tep_event *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")