Commit f847361e authored by swkhack's avatar swkhack Committed by Greg Kroah-Hartman

mm/mlock.c: change count_mm_mlocked_page_nr return type

[ Upstream commit 0874bb49bb21bf24deda853e8bf61b8325e24bcb ]

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.

Fixes: 0cf2f6f6 ("mm: mlock: check against vma for actual mlock() size")
Signed-off-by: default avatarswkhack <>
Acked-by: default avatarMichal Hocko <>
Reviewed-by: default avatarAndrew Morton <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
Signed-off-by: default avatarSasha Levin <>
parent 793ff5ef
......@@ -629,11 +629,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;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment