Skip to content

Commit e6e7a65

Browse files
fweisbecIngo Molnar
authored andcommitted
tracing/ftrace: fix unexpected -EINVAL when longest tracer name is set
Impact: fix confusing write() -EINVAL when changing the tracer The following commit d9e5407 remade alive the bug which made the set of a new tracer returning -EINVAL if this is the longest name of tracer. This patch corrects it. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent ee02a2e commit e6e7a65

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,6 +2655,9 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
26552655
char buf[max_tracer_type_len+1];
26562656
int i;
26572657
size_t ret;
2658+
int err;
2659+
2660+
ret = cnt;
26582661

26592662
if (cnt > max_tracer_type_len)
26602663
cnt = max_tracer_type_len;
@@ -2668,12 +2671,11 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
26682671
for (i = cnt - 1; i > 0 && isspace(buf[i]); i--)
26692672
buf[i] = 0;
26702673

2671-
ret = tracing_set_tracer(buf);
2672-
if (!ret)
2673-
ret = cnt;
2674+
err = tracing_set_tracer(buf);
2675+
if (err)
2676+
return err;
26742677

2675-
if (ret > 0)
2676-
filp->f_pos += ret;
2678+
filp->f_pos += ret;
26772679

26782680
return ret;
26792681
}

0 commit comments

Comments
 (0)