diff options
-rw-r--r-- | mm/fadvise.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/mm/fadvise.c b/mm/fadvise.c index b8024fa7101d..6c707bfe02fd 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c | |||
@@ -126,6 +126,17 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice) | |||
126 | */ | 126 | */ |
127 | start_index = (offset+(PAGE_SIZE-1)) >> PAGE_SHIFT; | 127 | start_index = (offset+(PAGE_SIZE-1)) >> PAGE_SHIFT; |
128 | end_index = (endbyte >> PAGE_SHIFT); | 128 | end_index = (endbyte >> PAGE_SHIFT); |
129 | if ((endbyte & ~PAGE_MASK) != ~PAGE_MASK) { | ||
130 | /* First page is tricky as 0 - 1 = -1, but pgoff_t | ||
131 | * is unsigned, so the end_index >= start_index | ||
132 | * check below would be true and we'll discard the whole | ||
133 | * file cache which is not what was asked. | ||
134 | */ | ||
135 | if (end_index == 0) | ||
136 | break; | ||
137 | |||
138 | end_index--; | ||
139 | } | ||
129 | 140 | ||
130 | if (end_index >= start_index) { | 141 | if (end_index >= start_index) { |
131 | unsigned long count = invalidate_mapping_pages(mapping, | 142 | unsigned long count = invalidate_mapping_pages(mapping, |