Skip to content

Commit 0874bb4

Browse files
sevicotorvalds
authored andcommitted
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: 0cf2f6f ("mm: mlock: check against vma for actual mlock() size") Signed-off-by: swkhack <swkhack@gmail.com> Acked-by: Michal Hocko <mhocko@suse.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7a30df4 commit 0874bb4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mm/mlock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,11 @@ static int apply_vma_lock_flags(unsigned long start, size_t len,
636636
* is also counted.
637637
* Return value: previously mlocked page counts
638638
*/
639-
static int count_mm_mlocked_page_nr(struct mm_struct *mm,
639+
static unsigned long count_mm_mlocked_page_nr(struct mm_struct *mm,
640640
unsigned long start, size_t len)
641641
{
642642
struct vm_area_struct *vma;
643-
int count = 0;
643+
unsigned long count = 0;
644644

645645
if (mm == NULL)
646646
mm = current->mm;

0 commit comments

Comments
 (0)