Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1338114d authored by Al Viro's avatar Al Viro Committed by Matt Wagantall
Browse files

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.

Change-Id: I5a465c3a740c4fe097068ec30d2cea00aa4bb457
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>
Git-commit: 801a76050bcf8d4e500eb8d048ff6265f37a61c8
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


Signed-off-by: default avatarMatt Wagantall <mattw@codeaurora.org>
parent e27e7a0b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ static int traverse(struct seq_file *m, loff_t offset)
Eoverflow:
	m->op->stop(m, p);
	kfree(m->buf);
	m->count = 0;
	m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
	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)
			goto Fill;
		m->op->stop(m, p);
		kfree(m->buf);
		m->count = 0;
		m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
		if (!m->buf)
			goto Enomem;
		m->count = 0;
		m->version = 0;
		pos = m->index;
		p = m->op->start(m, &pos);