tracing: Use seq_buf_used() in seq_buf_to_user() instead of len
authorJerry Snitselaar <jsnitsel@redhat.com>
Mon, 16 Nov 2015 19:57:28 +0000 (12:57 -0700)
committerSteven Rostedt <rostedt@goodmis.org>
Wed, 23 Dec 2015 19:27:20 +0000 (14:27 -0500)
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.

Link: http://lkml.kernel.org/r/1447703848-2951-1-git-send-email-jsnitsel@redhat.com
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
lib/seq_buf.c

index 5c94e1012a91f9ea65b20ca130f3f4aa4fb337f5..cb18469e1f490066fe36dcc6e3f8127ddc6a98da 100644 (file)
@@ -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);
This page took 0.031606 seconds and 5 git commands to generate.