Skip to contentSkip to conversation

tracing: Fix trace_event_raw_event_synth() if else statement

PATCH In review Steven Rostedt 2 participants 3 messages Jan 31, 2023 Tracing

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH 1/1 tracing: Fix trace_event_raw_event_synth() if else statement

From: "Steven Rostedt (Google)" <[email protected]>

The test to check if the field is a stack is to be done if it is not a string. But the code had:

    } if (event->fields[i]->is_stack) {

and not

   } else if (event->fields[i]->is_stack) {

which would cause it to always be tested. Worse yet, this also included an "else" statement that was only to be called if the field was not a string and a stack, but this code allows it to be called if it was a string (and not a stack).

Also fixed some whitespace issues.

Fixes 00cf3d672a9d ("tracing: Allow synthetic events to pass around stacktraces")
---
 kernel/trace/trace_events_synth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_events_synth.c +2 -2
index adb630633f31..306c89e0ce55 100644
@@ -564,8 +564,8 @@ static notrace void trace_event_raw_event_synth(void *__data,
 					   event->fields[i]->is_dynamic,
 					   data_size, &n_u64);
 			data_size += len; /* only dynamic string increments */
-		} if (event->fields[i]->is_stack) {
-		        long *stack = (long *)(long)var_ref_vals[val_idx];
+		} else if (event->fields[i]->is_stack) {
+			long *stack = (long *)(long)var_ref_vals[val_idx];
 
 			len = trace_stack(entry, event, stack,
 					   data_size, &n_u64);
Signature · 1 line
2.39.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Tue, 31 Jan 2023 09:52:37 -0500 Steven Rostedt <[email protected]> wrote:

From: "Steven Rostedt (Google)" <[email protected]>

The test to check if the field is a stack is to be done if it is not a string. But the code had:

    } if (event->fields[i]->is_stack) {

and not

Quoted 9 lines
   } else if (event->fields[i]->is_stack) {

which would cause it to always be tested. Worse yet, this also included an "else" statement that was only to be called if the field was not a string and a stack, but this code allows it to be called if it was a string (and not a stack).

Also fixed some whitespace issues.

Looks good to me.

Hmm, I need to add more tests for syntax events...

Thanks!

Quoted 27 lines
Fixes 00cf3d672a9d ("tracing: Allow synthetic events to pass around stacktraces")
---
 kernel/trace/trace_events_synth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_events_synth.c +2 -2
index adb630633f31..306c89e0ce55 100644
@@ -564,8 +564,8 @@ static notrace void trace_event_raw_event_synth(void *__data,
 					   event->fields[i]->is_dynamic,
 					   data_size, &n_u64);
 			data_size += len; /* only dynamic string increments */
-		} if (event->fields[i]->is_stack) {
-		        long *stack = (long *)(long)var_ref_vals[val_idx];
+		} else if (event->fields[i]->is_stack) {
+			long *stack = (long *)(long)var_ref_vals[val_idx];
 
 			len = trace_stack(entry, event, stack,
 					   data_size, &n_u64);
Signature · 1 line
2.39.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
author maintainer
#2 lore raw
Quoted 5 lines · On Wed, 1 Feb 2023 00:36:33 +0900 Masami Hiramatsu (Google)…

Looks good to me.

Hmm, I need to add more tests for syntax events...

I was thinking the same thing, as they should have caught this ;-)

-- Steve