Merge branch 'master' of ssh://master.kernel.org/pub/scm/linux/kernel/git/torvalds...
[firefly-linux-kernel-4.4.55.git] / mm / memory.c
index 607098d47e745b37d375c0aa49d63e5507a9f4b0..27f425378112ccd2c4b235217c3c6868f0d33044 100644 (file)
@@ -1359,7 +1359,7 @@ split_fallthrough:
                 */
                mark_page_accessed(page);
        }
-       if (flags & FOLL_MLOCK) {
+       if ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) {
                /*
                 * The preliminary mapping check is mainly to avoid the
                 * pointless overhead of lock_page on the ZERO_PAGE
@@ -1552,10 +1552,9 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
                }
 
                /*
-                * If we don't actually want the page itself,
-                * and it's the stack guard page, just skip it.
+                * For mlock, just skip the stack guard page.
                 */
-               if (!pages && stack_guard_page(vma, start))
+               if ((gup_flags & FOLL_MLOCK) && stack_guard_page(vma, start))
                        goto next_page;
 
                do {