summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2007-02-14 12:39:01 +0100
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-15 18:57:03 +0100
commite0a04cffa4e97e1e53625e40e70895c882e8972f (patch)
treef76ca38a59f07929ecfbc1caf6609eea67a8854c /mm
parent[PATCH] mincore: fill in results properly (diff)
downloadlinux-e0a04cffa4e97e1e53625e40e70895c882e8972f.tar.xz
linux-e0a04cffa4e97e1e53625e40e70895c882e8972f.zip
[PATCH] mincore: vma crossing fix
My mincore also forgot about crossing vmas. Signed-off-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/mincore.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/mm/mincore.c b/mm/mincore.c
index 9c1d0a426e95..5efe0ded69b1 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -77,8 +77,16 @@ static long do_mincore(unsigned long addr, unsigned char *vec, unsigned long pag
* PTE array for our address.
*/
nr = PTRS_PER_PTE - ((addr >> PAGE_SHIFT) & (PTRS_PER_PTE-1));
- if (nr > pages)
- nr = pages;
+
+ /*
+ * Don't overrun this vma
+ */
+ nr = min(nr, (vma->vm_end - addr) >> PAGE_SHIFT);
+
+ /*
+ * Don't return more than the caller asked for
+ */
+ nr = min(nr, pages);
pgd = pgd_offset(vma->vm_mm, addr);
if (pgd_none_or_clear_bad(pgd))