Skip to content

Commit 801a760

Browse files
Al Virotorvalds
authored andcommitted
seq_file: always clear m->count when we free m->buf
Once we'd freed m->buf, m->count should become zero - we have no valid contents reachable via m->buf. Reported-by: Charley (Hao Chuan) Chu <charley.chu@broadcom.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 27b5c3f commit 801a760

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎fs/seq_file.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ static int traverse(struct seq_file *m, loff_t offset)
136136
Eoverflow:
137137
m->op->stop(m, p);
138138
kfree(m->buf);
139+
m->count = 0;
139140
m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
140141
return !m->buf ? -ENOMEM : -EAGAIN;
141142
}
@@ -232,10 +233,10 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
232233
goto Fill;
233234
m->op->stop(m, p);
234235
kfree(m->buf);
236+
m->count = 0;
235237
m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
236238
if (!m->buf)
237239
goto Enomem;
238-
m->count = 0;
239240
m->version = 0;
240241
pos = m->index;
241242
p = m->op->start(m, &pos);

0 commit comments

Comments
 (0)