Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6e7a65a authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Ingo Molnar
Browse files

tracing/ftrace: fix unexpected -EINVAL when longest tracer name is set



Impact: fix confusing write() -EINVAL when changing the tracer

The following commit d9e54076 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: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent ee02a2e5
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -2655,6 +2655,9 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
	char buf[max_tracer_type_len+1];
	int i;
	size_t ret;
	int err;

	ret = cnt;

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

	ret = tracing_set_tracer(buf);
	if (!ret)
		ret = cnt;
	err = tracing_set_tracer(buf);
	if (err)
		return err;

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

	return ret;