Skip to content

Commit

Permalink
tracing: Don't use p->len field to determine output in __print_*() fu…
Browse files Browse the repository at this point in the history
…nctions

If more than one __print_*() function is used in a tracepoint
(__print_flags(), __print_symbols(), etc), then the temp seq buffer will
not be zero on entry. Using the temp seq buffer's length to know if
data has been printed or not in the current function is incorrect and
may produce incorrect results.

Currently, no in-tree tracepoint causes this bug, but new ones may
be created.

Cc: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Feb 21, 2012
1 parent e404b32 commit 5b34926
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/trace/trace_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ ftrace_print_flags_seq(struct trace_seq *p, const char *delim,

/* check for left over flags */
if (flags) {
if (p->len && delim)
if (!first && delim)
trace_seq_puts(p, delim);
trace_seq_printf(p, "0x%lx", flags);
}
Expand All @@ -346,7 +346,7 @@ ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val,
break;
}

if (!p->len)
if (ret == (const char *)(p->buffer + p->len))
trace_seq_printf(p, "0x%lx", val);

trace_seq_putc(p, 0);
Expand All @@ -372,7 +372,7 @@ ftrace_print_symbols_seq_u64(struct trace_seq *p, unsigned long long val,
break;
}

if (!p->len)
if (ret == (const char *)(p->buffer + p->len))
trace_seq_printf(p, "0x%llx", val);

trace_seq_putc(p, 0);
Expand Down

0 comments on commit 5b34926

Please sign in to comment.