diff options
-rw-r--r-- | kernel/trace/trace.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index caa4051ce778..78d56614c95b 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -2381,9 +2381,11 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, | |||
2381 | struct tracer *t; | 2381 | struct tracer *t; |
2382 | char buf[max_tracer_type_len+1]; | 2382 | char buf[max_tracer_type_len+1]; |
2383 | int i; | 2383 | int i; |
2384 | size_t ret; | ||
2384 | 2385 | ||
2385 | if (cnt > max_tracer_type_len) | 2386 | if (cnt > max_tracer_type_len) |
2386 | cnt = max_tracer_type_len; | 2387 | cnt = max_tracer_type_len; |
2388 | ret = cnt; | ||
2387 | 2389 | ||
2388 | if (copy_from_user(&buf, ubuf, cnt)) | 2390 | if (copy_from_user(&buf, ubuf, cnt)) |
2389 | return -EFAULT; | 2391 | return -EFAULT; |
@@ -2399,7 +2401,11 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, | |||
2399 | if (strcmp(t->name, buf) == 0) | 2401 | if (strcmp(t->name, buf) == 0) |
2400 | break; | 2402 | break; |
2401 | } | 2403 | } |
2402 | if (!t || t == current_trace) | 2404 | if (!t) { |
2405 | ret = -EINVAL; | ||
2406 | goto out; | ||
2407 | } | ||
2408 | if (t == current_trace) | ||
2403 | goto out; | 2409 | goto out; |
2404 | 2410 | ||
2405 | if (current_trace && current_trace->reset) | 2411 | if (current_trace && current_trace->reset) |
@@ -2412,9 +2418,10 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, | |||
2412 | out: | 2418 | out: |
2413 | mutex_unlock(&trace_types_lock); | 2419 | mutex_unlock(&trace_types_lock); |
2414 | 2420 | ||
2415 | filp->f_pos += cnt; | 2421 | if (ret == cnt) |
2422 | filp->f_pos += cnt; | ||
2416 | 2423 | ||
2417 | return cnt; | 2424 | return ret; |
2418 | } | 2425 | } |
2419 | 2426 | ||
2420 | static ssize_t | 2427 | static ssize_t |