diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-09-22 01:52:20 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-09-22 04:28:55 -0400 |
commit | 4ba7978e98a3ff92cebfb0f31a02c309e3ffa1fe (patch) | |
tree | 47d8b3b0927a7413fabcc634023b45350f344d89 /kernel/trace | |
parent | 3c235a337e205da0f614e456be72881483dcde6e (diff) |
tracing: Check the return value of trace_get_user()
Return immediately if trace_get_user() returned failure.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <4AB86614.7020803@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace')
-rw-r--r-- | kernel/trace/ftrace.c | 9 | ||||
-rw-r--r-- | kernel/trace/trace_events.c | 7 |
2 files changed, 7 insertions, 9 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index c71e91bf7372..a8fe4782ebad 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -2202,7 +2202,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, | |||
2202 | struct trace_parser *parser; | 2202 | struct trace_parser *parser; |
2203 | ssize_t ret, read; | 2203 | ssize_t ret, read; |
2204 | 2204 | ||
2205 | if (!cnt || cnt < 0) | 2205 | if (!cnt) |
2206 | return 0; | 2206 | return 0; |
2207 | 2207 | ||
2208 | mutex_lock(&ftrace_regex_lock); | 2208 | mutex_lock(&ftrace_regex_lock); |
@@ -2216,7 +2216,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, | |||
2216 | parser = &iter->parser; | 2216 | parser = &iter->parser; |
2217 | read = trace_get_user(parser, ubuf, cnt, ppos); | 2217 | read = trace_get_user(parser, ubuf, cnt, ppos); |
2218 | 2218 | ||
2219 | if (trace_parser_loaded(parser) && | 2219 | if (read >= 0 && trace_parser_loaded(parser) && |
2220 | !trace_parser_cont(parser)) { | 2220 | !trace_parser_cont(parser)) { |
2221 | ret = ftrace_process_regex(parser->buffer, | 2221 | ret = ftrace_process_regex(parser->buffer, |
2222 | parser->idx, enable); | 2222 | parser->idx, enable); |
@@ -2552,8 +2552,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf, | |||
2552 | size_t cnt, loff_t *ppos) | 2552 | size_t cnt, loff_t *ppos) |
2553 | { | 2553 | { |
2554 | struct trace_parser parser; | 2554 | struct trace_parser parser; |
2555 | size_t read = 0; | 2555 | ssize_t read, ret; |
2556 | ssize_t ret; | ||
2557 | 2556 | ||
2558 | if (!cnt || cnt < 0) | 2557 | if (!cnt || cnt < 0) |
2559 | return 0; | 2558 | return 0; |
@@ -2572,7 +2571,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf, | |||
2572 | 2571 | ||
2573 | read = trace_get_user(&parser, ubuf, cnt, ppos); | 2572 | read = trace_get_user(&parser, ubuf, cnt, ppos); |
2574 | 2573 | ||
2575 | if (trace_parser_loaded((&parser))) { | 2574 | if (read >= 0 && trace_parser_loaded((&parser))) { |
2576 | parser.buffer[parser.idx] = 0; | 2575 | parser.buffer[parser.idx] = 0; |
2577 | 2576 | ||
2578 | /* we allow only one expression at a time */ | 2577 | /* we allow only one expression at a time */ |
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 6f03c8a1105e..d128f65778e6 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
@@ -232,10 +232,9 @@ ftrace_event_write(struct file *file, const char __user *ubuf, | |||
232 | size_t cnt, loff_t *ppos) | 232 | size_t cnt, loff_t *ppos) |
233 | { | 233 | { |
234 | struct trace_parser parser; | 234 | struct trace_parser parser; |
235 | size_t read = 0; | 235 | ssize_t read, ret; |
236 | ssize_t ret; | ||
237 | 236 | ||
238 | if (!cnt || cnt < 0) | 237 | if (!cnt) |
239 | return 0; | 238 | return 0; |
240 | 239 | ||
241 | ret = tracing_update_buffers(); | 240 | ret = tracing_update_buffers(); |
@@ -247,7 +246,7 @@ ftrace_event_write(struct file *file, const char __user *ubuf, | |||
247 | 246 | ||
248 | read = trace_get_user(&parser, ubuf, cnt, ppos); | 247 | read = trace_get_user(&parser, ubuf, cnt, ppos); |
249 | 248 | ||
250 | if (trace_parser_loaded((&parser))) { | 249 | if (read >= 0 && trace_parser_loaded((&parser))) { |
251 | int set = 1; | 250 | int set = 1; |
252 | 251 | ||
253 | if (*parser.buffer == '!') | 252 | if (*parser.buffer == '!') |