diff options
author | Jerry Snitselaar <jsnitsel@redhat.com> | 2015-11-16 14:57:28 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-12-23 14:27:20 -0500 |
commit | ff078d8fc644722f7b163d79e8a03b00b9dc2385 (patch) | |
tree | 54ed114e88d8d85899d3e9821d6ff4523b726291 | |
parent | 27dff4e04199cf0ecf06239a26d0d225d3c046e9 (diff) |
tracing: Use seq_buf_used() in seq_buf_to_user() instead of len
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>
-rw-r--r-- | lib/seq_buf.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/seq_buf.c b/lib/seq_buf.c index 5c94e1012a91..cb18469e1f49 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) | |||
306 | if (!cnt) | 306 | if (!cnt) |
307 | return 0; | 307 | return 0; |
308 | 308 | ||
309 | if (s->len <= s->readpos) | 309 | len = seq_buf_used(s); |
310 | |||
311 | if (len <= s->readpos) | ||
310 | return -EBUSY; | 312 | return -EBUSY; |
311 | 313 | ||
312 | len = seq_buf_used(s) - s->readpos; | 314 | len -= s->readpos; |
313 | if (cnt > len) | 315 | if (cnt > len) |
314 | cnt = len; | 316 | cnt = len; |
315 | ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt); | 317 | ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt); |