Commit 801a7605 authored by Al Viro's avatar Al Viro Committed by Linus Torvalds

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: default avatarCharley (Hao Chuan) Chu <charley.chu@broadcom.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 27b5c3f3
...@@ -136,6 +136,7 @@ static int traverse(struct seq_file *m, loff_t offset) ...@@ -136,6 +136,7 @@ static int traverse(struct seq_file *m, loff_t offset)
Eoverflow: Eoverflow:
m->op->stop(m, p); m->op->stop(m, p);
kfree(m->buf); kfree(m->buf);
m->count = 0;
m->buf = kmalloc(m->size <<= 1, GFP_KERNEL); m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
return !m->buf ? -ENOMEM : -EAGAIN; return !m->buf ? -ENOMEM : -EAGAIN;
} }
...@@ -232,10 +233,10 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) ...@@ -232,10 +233,10 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
goto Fill; goto Fill;
m->op->stop(m, p); m->op->stop(m, p);
kfree(m->buf); kfree(m->buf);
m->count = 0;
m->buf = kmalloc(m->size <<= 1, GFP_KERNEL); m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
if (!m->buf) if (!m->buf)
goto Enomem; goto Enomem;
m->count = 0;
m->version = 0; m->version = 0;
pos = m->index; pos = m->index;
p = m->op->start(m, &pos); p = m->op->start(m, &pos);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment