mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tracing: use seq_buf_used() in seq_buf_to_user() instead of len
@ 2015-11-16 19:57 Jerry Snitselaar
  2015-12-23 16:09 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Jerry Snitselaar @ 2015-11-16 19:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Steven Rostedt (Red Hat)

commit 5ac48378414d ("tracing: Use trace_seq_used() and seq_buf_used()
instead of len") changed the tracing code to use trace_seq_used() and
seq_buf_used() instead of using the seq_buf len directly to avoid
overflow issues, but missed a spot in seq_buf_to_user() that makes use
of s->len.

Cleaned up the code a bit as well per suggestion of Steve Rostedt.

Cc: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
 lib/seq_buf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/seq_buf.c b/lib/seq_buf.c
index 5c94e10..cb18469 100644
--- a/lib/seq_buf.c
+++ b/lib/seq_buf.c
@@ -306,10 +306,12 @@ int seq_buf_to_user(struct seq_buf *s, char __user *ubuf, int cnt)
 	if (!cnt)
 		return 0;
 
-	if (s->len <= s->readpos)
+	len = seq_buf_used(s);
+
+	if (len <= s->readpos)
 		return -EBUSY;
 
-	len = seq_buf_used(s) - s->readpos;
+	len -= s->readpos;
 	if (cnt > len)
 		cnt = len;
 	ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt);
-- 
2.6.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-23 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-16 19:57 [PATCH] tracing: use seq_buf_used() in seq_buf_to_user() instead of len Jerry Snitselaar
2015-12-23 16:09 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®