Skip to contentSkip to conversation

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

PATCH New Franck Bui-Huu 1 participant 1 message Oct 10, 2008 VFS

lore
Share & tools
lore
#0 lore raw

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

From: Franck Bui-Huu <[email protected]>

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.

---
 fs/seq_file.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/seq_file.c +2 -2
index bd20f7f..b9d5b37 100644
@@ -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);
Signature · 1 line
1.6.0.2.GIT