From: Franck Bui-Huu <vagabon.xyz@gmail.com>
To: viro@ZenIV.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] Fix seq_read() in first loop when m->buf is too small
Date: Fri, 10 Oct 2008 09:33:30 +0200 [thread overview]
Message-ID: <48EF054A.6010705@gmail.com> (raw)
From: Franck Bui-Huu <fbuihuu@gmail.com>
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 <fbuihuu@gmail.com>
---
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
reply other threads:[~2008-10-10 7:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48EF054A.6010705@gmail.com \
--to=vagabon.xyz@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.