Commit 4ba7978e authored by Li Zefan's avatar Li Zefan Committed by Ingo Molnar

tracing: Check the return value of trace_get_user()

Return immediately if trace_get_user() returned failure.
Signed-off-by: default avatarLi 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: default avatarIngo Molnar <mingo@elte.hu>
parent 3c235a33
...@@ -2202,7 +2202,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, ...@@ -2202,7 +2202,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
struct trace_parser *parser; struct trace_parser *parser;
ssize_t ret, read; ssize_t ret, read;
if (!cnt || cnt < 0) if (!cnt)
return 0; return 0;
mutex_lock(&ftrace_regex_lock); mutex_lock(&ftrace_regex_lock);
...@@ -2216,7 +2216,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, ...@@ -2216,7 +2216,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
parser = &iter->parser; parser = &iter->parser;
read = trace_get_user(parser, ubuf, cnt, ppos); read = trace_get_user(parser, ubuf, cnt, ppos);
if (trace_parser_loaded(parser) && if (read >= 0 && trace_parser_loaded(parser) &&
!trace_parser_cont(parser)) { !trace_parser_cont(parser)) {
ret = ftrace_process_regex(parser->buffer, ret = ftrace_process_regex(parser->buffer,
parser->idx, enable); parser->idx, enable);
...@@ -2552,8 +2552,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf, ...@@ -2552,8 +2552,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
size_t cnt, loff_t *ppos) size_t cnt, loff_t *ppos)
{ {
struct trace_parser parser; struct trace_parser parser;
size_t read = 0; ssize_t read, ret;
ssize_t ret;
if (!cnt || cnt < 0) if (!cnt || cnt < 0)
return 0; return 0;
...@@ -2572,7 +2571,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf, ...@@ -2572,7 +2571,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
read = trace_get_user(&parser, ubuf, cnt, ppos); read = trace_get_user(&parser, ubuf, cnt, ppos);
if (trace_parser_loaded((&parser))) { if (read >= 0 && trace_parser_loaded((&parser))) {
parser.buffer[parser.idx] = 0; parser.buffer[parser.idx] = 0;
/* we allow only one expression at a time */ /* we allow only one expression at a time */
......
...@@ -232,10 +232,9 @@ ftrace_event_write(struct file *file, const char __user *ubuf, ...@@ -232,10 +232,9 @@ ftrace_event_write(struct file *file, const char __user *ubuf,
size_t cnt, loff_t *ppos) size_t cnt, loff_t *ppos)
{ {
struct trace_parser parser; struct trace_parser parser;
size_t read = 0; ssize_t read, ret;
ssize_t ret;
if (!cnt || cnt < 0) if (!cnt)
return 0; return 0;
ret = tracing_update_buffers(); ret = tracing_update_buffers();
...@@ -247,7 +246,7 @@ ftrace_event_write(struct file *file, const char __user *ubuf, ...@@ -247,7 +246,7 @@ ftrace_event_write(struct file *file, const char __user *ubuf,
read = trace_get_user(&parser, ubuf, cnt, ppos); read = trace_get_user(&parser, ubuf, cnt, ppos);
if (trace_parser_loaded((&parser))) { if (read >= 0 && trace_parser_loaded((&parser))) {
int set = 1; int set = 1;
if (*parser.buffer == '!') if (*parser.buffer == '!')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment