History

tracing: Clear trace_state when starting trace

Clear trace_state data structure when starting trace in __synth_event_trace_start() internal function. Currently trace_state is initialized only in the synth_event_trace_start() API, but the trace_state in synth_event_trace() and synth_event_trace_array() are on the stack without initialization. This means those APIs will see wrong parameters and wil skip closing process in __synth_event_trace_end() because trace_state->disabled may be !0. Link: http://lkml.kernel.org/r/158193315899.8868.1781259176894639952.stgit@devnote2

Masami Hiramatsu committed 6 years ago

Commit 7ab215f1 parent 08d9e681 file · +2 −2Browse files

Showing the changes to kernel/trace (1 of 1 file). Show all

Unified · Split

kernel/trace/trace_events_hist.c+2−2
@@ -1824,6 +1824,8 @@ __synth_event_trace_start(struct trace_event_file *file, · 1823 unmodified lines
18241824 int entry_size, fields_size = 0;
18251825 int ret = 0;
18261826
1827+ memset(trace_state, '\0', sizeof(*trace_state));
1828+
18271829 /*
18281830 * Normal event tracing doesn't get called at all unless the
18291831 * ENABLED bit is set (which attaches the probe thus allowing
@@ -2063,8 +2065,6 @@ int synth_event_trace_start(struct trace_event_file *file, · 233 unmodified lines
20632065 if (!trace_state)
20642066 return -EINVAL;
20652067
2066− memset(trace_state, '\0', sizeof(*trace_state));
2067−
20682068 ret = __synth_event_trace_start(file, trace_state);
20692069 if (ret == -ENOENT)
20702070 ret = 0; /* just disabled, not really an error */