diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2008-10-28 10:44:24 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-28 11:33:47 -0400 |
commit | 60063a66236c15f5613f91390631e06718689782 (patch) | |
tree | 3625c15ade69e4f8cbb85d737290da1312123241 /kernel | |
parent | 21798a84ab383cdac0e7ee3368e0792b718b867d (diff) |
ftrace: fix current_tracer error return
The commit (in linux-tip) c2931e05ec5965597cbfb79ad332d4a29aeceb23
( ftrace: return an error when setting a nonexistent tracer )
added useful code that would error when a bad tracer was written into
the current_tracer file.
But this had a bug if the amount written was more than the amount read by
that code. The first iteration would set the tracer correctly, but since
it did not consume the rest of what was written (usually whitespace), the
userspace utility would continue to write what was not consumed. This
second iteration would fail to find a tracer and return -EINVAL. Funny
thing is that the tracer would have already been set.
This patch just consumes all the data that is written to the file.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index bc577dcc0e47..a610ca771558 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -2377,9 +2377,10 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, | |||
2377 | int i; | 2377 | int i; |
2378 | size_t ret; | 2378 | size_t ret; |
2379 | 2379 | ||
2380 | ret = cnt; | ||
2381 | |||
2380 | if (cnt > max_tracer_type_len) | 2382 | if (cnt > max_tracer_type_len) |
2381 | cnt = max_tracer_type_len; | 2383 | cnt = max_tracer_type_len; |
2382 | ret = cnt; | ||
2383 | 2384 | ||
2384 | if (copy_from_user(&buf, ubuf, cnt)) | 2385 | if (copy_from_user(&buf, ubuf, cnt)) |
2385 | return -EFAULT; | 2386 | return -EFAULT; |
@@ -2412,8 +2413,8 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, | |||
2412 | out: | 2413 | out: |
2413 | mutex_unlock(&trace_types_lock); | 2414 | mutex_unlock(&trace_types_lock); |
2414 | 2415 | ||
2415 | if (ret == cnt) | 2416 | if (ret > 0) |
2416 | filp->f_pos += cnt; | 2417 | filp->f_pos += ret; |
2417 | 2418 | ||
2418 | return ret; | 2419 | return ret; |
2419 | } | 2420 | } |