Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jerry Snitselaar and committed by
Steven Rostedt
ff078d8f 27dff4e0

+4 -2
+4 -2
lib/seq_buf.c
··· 306 306 if (!cnt) 307 307 return 0; 308 308 309 - if (s->len <= s->readpos) 309 + len = seq_buf_used(s); 310 + 311 + if (len <= s->readpos) 310 312 return -EBUSY; 311 313 312 - len = seq_buf_used(s) - s->readpos; 314 + len -= s->readpos; 313 315 if (cnt > len) 314 316 cnt = len; 315 317 ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt);