Skip to content

Commit

Permalink
ftrace: return an error when setting a nonexistent tracer
Browse files Browse the repository at this point in the history
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: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Oct 14, 2008
1 parent 3ea2e6d commit c2931e0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2381,9 +2381,11 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
struct tracer *t;
char buf[max_tracer_type_len+1];
int i;
size_t ret;

if (cnt > max_tracer_type_len)
cnt = max_tracer_type_len;
ret = cnt;

if (copy_from_user(&buf, ubuf, cnt))
return -EFAULT;
Expand All @@ -2399,7 +2401,11 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
if (strcmp(t->name, buf) == 0)
break;
}
if (!t || t == current_trace)
if (!t) {
ret = -EINVAL;
goto out;
}
if (t == current_trace)
goto out;

if (current_trace && current_trace->reset)
Expand All @@ -2412,9 +2418,10 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
out:
mutex_unlock(&trace_types_lock);

filp->f_pos += cnt;
if (ret == cnt)
filp->f_pos += cnt;

return cnt;
return ret;
}

static ssize_t
Expand Down

0 comments on commit c2931e0

Please sign in to comment.