diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-09-10 18:50:36 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-09-10 18:50:36 -0700 |
commit | 69cf90594e0de5ac25012c97de459e15bf0f1413 (patch) | |
tree | d306e3c83fac9f58c1a106fda1bdfb47ee4033c1 /mm | |
parent | 458a09d914f94cbca3a973277abebf1447f7ae3e (diff) | |
download | history-69cf90594e0de5ac25012c97de459e15bf0f1413.tar.gz |
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.
Diffstat (limited to 'mm')
-rw-r--r-- | mm/filemap.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 55fb7b4141e419..272c3e0a6fed2b 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -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; |