Skip to content

Commit

Permalink
mm/mlock.c: change count_mm_mlocked_page_nr return type
Browse files Browse the repository at this point in the history
On a 64-bit machine the value of "vma->vm_end - vma->vm_start" may be
negative when using 32 bit ints and the "count >> PAGE_SHIFT"'s result
will be wrong.  So change the local variable and return value to
unsigned long to fix the problem.

Link: http://lkml.kernel.org/r/[email protected]
Fixes: 0cf2f6f ("mm: mlock: check against vma for actual mlock() size")
Signed-off-by: swkhack <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
sevico authored and torvalds committed Jun 14, 2019
1 parent 7a30df4 commit 0874bb4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/mlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,11 @@ static int apply_vma_lock_flags(unsigned long start, size_t len,
* is also counted.
* Return value: previously mlocked page counts
*/
static int count_mm_mlocked_page_nr(struct mm_struct *mm,
static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm,
unsigned long start, size_t len)
{
struct vm_area_struct *vma;
int count = 0;
unsigned long count = 0;

if (mm == NULL)
mm = current->mm;
Expand Down

0 comments on commit 0874bb4

Please sign in to comment.