Skip to content

Commit

Permalink
seq_file: fix big-enough lseek() + read()
Browse files Browse the repository at this point in the history
lseek() further than length of the file will leave stale ->index
(second-to-last during iteration). Next seq_read() will not notice
that ->f_pos is big enough to return 0, but will print last item
as if ->f_pos is pointing to it.

Introduced in commit cb510b8
aka "seq_file: more atomicity in traverse()".

Signed-off-by: Alexey Dobriyan <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alexey Dobriyan authored and torvalds committed Feb 5, 2009
1 parent 33da889 commit f01d1d5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fs/seq_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ static int traverse(struct seq_file *m, loff_t offset)
p = m->op->next(m, p, &index);
}
m->op->stop(m, p);
m->index = index;
return error;

Eoverflow:
Expand Down

0 comments on commit f01d1d5

Please sign in to comment.