Commit 69cf9059 authored by Linus Torvalds's avatar Linus Torvalds

Fix off-by-one bug in page cache reading.

Just test the end case inside the loop, rather than trying to
be clever and getting it wrong.
parent 458a09d9
......@@ -732,16 +732,15 @@ void do_generic_mapping_read(struct address_space *mapping,
goto out;
end_index = (isize - 1) >> PAGE_CACHE_SHIFT;
if (index > end_index)
goto out;
for (;;) {
struct page *page;
unsigned long nr, ret;
/* nr is the maximum number of bytes to copy from this page */
nr = PAGE_CACHE_SIZE;
if (index == end_index) {
if (index >= end_index) {
if (index > end_index)
goto out;
nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1;
if (nr <= offset) {
goto out;
......
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