Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752127AbbKPT5l (ORCPT ); Mon, 16 Nov 2015 14:57:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48794 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbbKPT5k (ORCPT ); Mon, 16 Nov 2015 14:57:40 -0500 From: Jerry Snitselaar To: linux-kernel@vger.kernel.org Cc: "Steven Rostedt (Red Hat)" Subject: [PATCH] tracing: use seq_buf_used() in seq_buf_to_user() instead of len Date: Mon, 16 Nov 2015 12:57:28 -0700 Message-Id: <1447703848-2951-1-git-send-email-jsnitsel@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1277 Lines: 41 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)" Signed-off-by: Jerry Snitselaar --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/