From mboxrd@z Thu Jan 1 00:00:00 1970 From: Franck Bui-Huu Subject: [PATCH] Fix seq_read() in first loop when m->buf is too small Date: Fri, 10 Oct 2008 09:33:30 +0200 Message-ID: <48EF054A.6010705@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org To: viro@ZenIV.linux.org.uk Return-path: Received: from fg-out-1718.google.com ([72.14.220.153]:1319 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754606AbYJJHdn (ORCPT ); Fri, 10 Oct 2008 03:33:43 -0400 Received: by fg-out-1718.google.com with SMTP id 19so261580fgg.17 for ; Fri, 10 Oct 2008 00:33:42 -0700 (PDT) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Franck Bui-Huu op->show() has 2 ways to indicate there's not enough space in m->buf: m->count is always equal to m->size but the ret val of op->show() can be either 0 or <0. For the second case, which can happen when op->show() returns directly seq_printf() return value, the first loop doesn't retry with a bigger m->buf. This patch fixes this case. Signed-off-by: Franck Bui-Huu --- fs/seq_file.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/seq_file.c b/fs/seq_file.c index bd20f7f..b9d5b37 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -115,9 +115,9 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) if (!p || IS_ERR(p)) break; err = m->op->show(m, p); - if (err < 0) + if (err < 0 && m->count < m->size) break; - if (unlikely(err)) + if (unlikely(err > 0)) m->count = 0; if (unlikely(!m->count)) { p = m->op->next(m, p, &pos); -- 1.6.0.2.GIT