Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0874bb49 authored by swkhack's avatar swkhack Committed by Linus Torvalds
Browse files

mm/mlock.c: change count_mm_mlocked_page_nr return type

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/20190513023701.83056-1-swkhack@gmail.com


Fixes: 0cf2f6f6 ("mm: mlock: check against vma for actual mlock() size")
Signed-off-by: default avatarswkhack <swkhack@gmail.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7a30df49
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;