summaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-02-03 23:20:41 +0100
committerIngo Molnar <mingo@elte.hu>2009-02-04 20:48:30 +0100
commitd9793bd8018f835c64b10f44e278c86cecb8e932 (patch)
treeda5ad9bc8f3fc7b4eb4ecd398f7c52a6f112d544 /kernel/trace/trace.c
parentMerge branches 'tracing/blktrace', 'tracing/ftrace', 'tracing/urgent' and 'li... (diff)
downloadlinux-d9793bd8018f835c64b10f44e278c86cecb8e932.tar.xz
linux-d9793bd8018f835c64b10f44e278c86cecb8e932.zip
trace: judicious error checking of trace_seq results
Impact: bugfix and cleanup Some callsites were returning either TRACE_ITER_PARTIAL_LINE if the trace_seq routines (trace_seq_printf, etc) returned 0 meaning its buffer was full, or zero otherwise. But... /* Return values for print_line callback */ enum print_line_t { TRACE_TYPE_PARTIAL_LINE = 0, /* Retry after flushing the seq */ TRACE_TYPE_HANDLED = 1, TRACE_TYPE_UNHANDLED = 2 /* Relay to other output functions */ }; In other cases the return value was not being relayed at all. Most of the time it didn't hurt because the page wasn't get filled, but for correctness sake, handle the return values everywhere. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c75
1 files changed, 34 insertions, 41 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index bbdfaa2cbdb9..5822ff4e5a3e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1402,27 +1402,25 @@ static enum print_line_t print_lat_fmt(struct trace_iterator *iter)
unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK);
struct trace_event *event;
struct trace_entry *entry = iter->ent;
- int ret;
test_cpu_buff_start(iter);
event = ftrace_find_event(entry->type);
if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
- ret = trace_print_lat_context(iter);
- if (ret)
- return ret;
+ if (!trace_print_lat_context(iter))
+ goto partial;
}
- if (event && event->latency_trace) {
- ret = event->latency_trace(iter, sym_flags);
- if (ret)
- return ret;
- return TRACE_TYPE_HANDLED;
- }
+ if (event && event->latency_trace)
+ return event->latency_trace(iter, sym_flags);
+
+ if (!trace_seq_printf(s, "Unknown type %d\n", entry->type))
+ goto partial;
- trace_seq_printf(s, "Unknown type %d\n", entry->type);
return TRACE_TYPE_HANDLED;
+partial:
+ return TRACE_TYPE_PARTIAL_LINE;
}
static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
@@ -1431,7 +1429,6 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK);
struct trace_entry *entry;
struct trace_event *event;
- int ret;
entry = iter->ent;
@@ -1440,22 +1437,19 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
event = ftrace_find_event(entry->type);
if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
- ret = trace_print_context(iter);
- if (ret)
- return ret;
+ if (!trace_print_context(iter))
+ goto partial;
}
- if (event && event->trace) {
- ret = event->trace(iter, sym_flags);
- if (ret)
- return ret;
- return TRACE_TYPE_HANDLED;
- }
- ret = trace_seq_printf(s, "Unknown type %d\n", entry->type);
- if (!ret)
- return TRACE_TYPE_PARTIAL_LINE;
+ if (event && event->trace)
+ return event->trace(iter, sym_flags);
+
+ if (!trace_seq_printf(s, "Unknown type %d\n", entry->type))
+ goto partial;
return TRACE_TYPE_HANDLED;
+partial:
+ return TRACE_TYPE_PARTIAL_LINE;
}
static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
@@ -1463,29 +1457,25 @@ static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
struct trace_seq *s = &iter->seq;
struct trace_entry *entry;
struct trace_event *event;
- int ret;
entry = iter->ent;
if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
- ret = trace_seq_printf(s, "%d %d %llu ",
- entry->pid, iter->cpu, iter->ts);
- if (!ret)
- return TRACE_TYPE_PARTIAL_LINE;
+ if (!trace_seq_printf(s, "%d %d %llu ",
+ entry->pid, iter->cpu, iter->ts))
+ goto partial;
}
event = ftrace_find_event(entry->type);
- if (event && event->raw) {
- ret = event->raw(iter, 0);
- if (ret)
- return ret;
- return TRACE_TYPE_HANDLED;
- }
- ret = trace_seq_printf(s, "%d ?\n", entry->type);
- if (!ret)
- return TRACE_TYPE_PARTIAL_LINE;
+ if (event && event->raw)
+ return event->raw(iter, 0);
+
+ if (!trace_seq_printf(s, "%d ?\n", entry->type))
+ goto partial;
return TRACE_TYPE_HANDLED;
+partial:
+ return TRACE_TYPE_PARTIAL_LINE;
}
static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
@@ -1504,8 +1494,11 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
}
event = ftrace_find_event(entry->type);
- if (event && event->hex)
- event->hex(iter, 0);
+ if (event && event->hex) {
+ int ret = event->hex(iter, 0);
+ if (ret != TRACE_TYPE_HANDLED)
+ return ret;
+ }
SEQ_PUT_FIELD_RET(s, newline);
@@ -1544,7 +1537,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
event = ftrace_find_event(entry->type);
if (event && event->binary)
- event->binary(iter, 0);
+ return event->binary(iter, 0);
return TRACE_TYPE_HANDLED;
}