LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: "Ingo Molnar" <mingo@elte.hu>,
	"Frédéric Weisbecker" <fweisbec@gmail.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Linus Torvalds" <torvalds@linux-foundation.org>
Subject: [PATCH] ftrace: fix current_tracer error return
Date: Tue, 28 Oct 2008 10:44:24 -0400 (EDT)	[thread overview]
Message-ID: <alpine.DEB.1.10.0810281039130.29482@gandalf.stny.rr.com> (raw)
In-Reply-To: <c62985530810280202r694a23e8l5233d892b3aa4330@mail.gmail.com>


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>
---
 kernel/trace/trace.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Index: linux-tip.git/kernel/trace/trace.c
===================================================================
--- linux-tip.git.orig/kernel/trace/trace.c	2008-10-28 10:23:41.000000000 -0400
+++ linux-tip.git/kernel/trace/trace.c	2008-10-28 10:25:58.000000000 -0400
@@ -2399,9 +2399,10 @@ tracing_set_trace_write(struct file *fil
 	int i;
 	size_t ret;
 
+	ret = cnt;
+
 	if (cnt > max_tracer_type_len)
 		cnt = max_tracer_type_len;
-	ret = cnt;
 
 	if (copy_from_user(&buf, ubuf, cnt))
 		return -EFAULT;
@@ -2434,8 +2435,8 @@ tracing_set_trace_write(struct file *fil
  out:
 	mutex_unlock(&trace_types_lock);
 
-	if (ret == cnt)
-		filp->f_pos += cnt;
+	if (ret > 0)
+		filp->f_pos += ret;
 
 	return ret;
 }



  parent reply	other threads:[~2008-10-28 15:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-27 23:18 Ftrace doesn't work anymore on latest tip Frédéric Weisbecker
2008-10-27 23:36 ` Steven Rostedt
2008-10-27 23:44   ` Frédéric Weisbecker
2008-10-28  9:02     ` Frédéric Weisbecker
2008-10-28 14:23       ` Steven Rostedt
2008-10-28 14:44       ` Steven Rostedt [this message]
2008-10-28 15:35         ` [PATCH] ftrace: fix current_tracer error return Frédéric Weisbecker
2008-10-28 15:41           ` Steven Rostedt
2008-10-28 18:15             ` Frédéric Weisbecker
2008-10-28 18:32               ` Steven Rostedt
2008-10-29  0:34                 ` Frédéric Weisbecker
2008-10-29  0:55                   ` Steven Rostedt
2008-10-29  1:09                     ` Frédéric Weisbecker
2008-10-29  1:11                       ` Steven Rostedt
2008-10-29  8:35                         ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.1.10.0810281039130.29482@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@linux-foundation.org \
    --subject='Re: [PATCH] ftrace: fix current_tracer error return' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).