Commit c2931e05 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Ingo Molnar

ftrace: return an error when setting a nonexistent tracer

When one try to set a nonexistent tracer, no error is returned
as if the name of the tracer was correct.
We should return -EINVAL.
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Acked-by: default avatarSteven Rostedt <srostedt@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 3ea2e6d7
...@@ -2381,9 +2381,11 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, ...@@ -2381,9 +2381,11 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
struct tracer *t; struct tracer *t;
char buf[max_tracer_type_len+1]; char buf[max_tracer_type_len+1];
int i; int i;
size_t ret;
if (cnt > max_tracer_type_len) if (cnt > max_tracer_type_len)
cnt = max_tracer_type_len; cnt = max_tracer_type_len;
ret = cnt;
if (copy_from_user(&buf, ubuf, cnt)) if (copy_from_user(&buf, ubuf, cnt))
return -EFAULT; return -EFAULT;
...@@ -2399,7 +2401,11 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, ...@@ -2399,7 +2401,11 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
if (strcmp(t->name, buf) == 0) if (strcmp(t->name, buf) == 0)
break; break;
} }
if (!t || t == current_trace) if (!t) {
ret = -EINVAL;
goto out;
}
if (t == current_trace)
goto out; goto out;
if (current_trace && current_trace->reset) if (current_trace && current_trace->reset)
...@@ -2412,9 +2418,10 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, ...@@ -2412,9 +2418,10 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
out: out:
mutex_unlock(&trace_types_lock); mutex_unlock(&trace_types_lock);
filp->f_pos += cnt; if (ret == cnt)
filp->f_pos += cnt;
return cnt; return ret;
} }
static ssize_t static ssize_t
......
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