diff options
author | Al Viro <viro@ZenIV.linux.org.uk> | 2013-11-18 20:20:43 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-18 22:07:53 -0500 |
commit | 801a76050bcf8d4e500eb8d048ff6265f37a61c8 (patch) | |
tree | 261258d2a4f61f07f238c18ea1087fca6eea9947 /fs | |
parent | 27b5c3f3cc9c5ce0702db1cca718c827e8b689e9 (diff) |
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/seq_file.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index 1cd2388ca5bd..1d641bb108d2 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -136,6 +136,7 @@ static int traverse(struct seq_file *m, loff_t offset) | |||
136 | Eoverflow: | 136 | Eoverflow: |
137 | m->op->stop(m, p); | 137 | m->op->stop(m, p); |
138 | kfree(m->buf); | 138 | kfree(m->buf); |
139 | m->count = 0; | ||
139 | m->buf = kmalloc(m->size <<= 1, GFP_KERNEL); | 140 | m->buf = kmalloc(m->size <<= 1, GFP_KERNEL); |
140 | return !m->buf ? -ENOMEM : -EAGAIN; | 141 | return !m->buf ? -ENOMEM : -EAGAIN; |
141 | } | 142 | } |
@@ -232,10 +233,10 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) | |||
232 | goto Fill; | 233 | goto Fill; |
233 | m->op->stop(m, p); | 234 | m->op->stop(m, p); |
234 | kfree(m->buf); | 235 | kfree(m->buf); |
236 | m->count = 0; | ||
235 | m->buf = kmalloc(m->size <<= 1, GFP_KERNEL); | 237 | m->buf = kmalloc(m->size <<= 1, GFP_KERNEL); |
236 | if (!m->buf) | 238 | if (!m->buf) |
237 | goto Enomem; | 239 | goto Enomem; |
238 | m->count = 0; | ||
239 | m->version = 0; | 240 | m->version = 0; |
240 | pos = m->index; | 241 | pos = m->index; |
241 | p = m->op->start(m, &pos); | 242 | p = m->op->start(m, &pos); |