Skip to content

Commit

Permalink
[PATCH] mincore: vma crossing fix
Browse files Browse the repository at this point in the history
My mincore also forgot about crossing vmas.

Signed-off-by: Nick Piggin <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed Feb 15, 2007
1 parent 4a76ef0 commit e0a04cf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mm/mincore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit e0a04cf

Please sign in to comment.