net/mlx4_en: Resolve dividing by zero in 32-bit system
[cascardo/linux.git] / mm / mlock.c
index b1fec89..145a425 100644 (file)
@@ -516,6 +516,7 @@ static int mlock_fixup(struct vm_area_struct *vma, struct vm_area_struct **prev,
        int nr_pages;
        int ret = 0;
        int lock = !!(newflags & VM_LOCKED);
+       vm_flags_t old_flags = vma->vm_flags;
 
        if (newflags == vma->vm_flags || (vma->vm_flags & VM_SPECIAL) ||
            is_vm_hugetlb_page(vma) || vma == get_gate_vma(current->mm))
@@ -550,6 +551,8 @@ success:
        nr_pages = (end - start) >> PAGE_SHIFT;
        if (!lock)
                nr_pages = -nr_pages;
+       else if (old_flags & VM_LOCKED)
+               nr_pages = 0;
        mm->locked_vm += nr_pages;
 
        /*