[PATCH] Fix seq_read() in first loop when m->buf is too small

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Franck Bui-Huu <fbuihuu@xxxxxxxxx>

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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux