summaryrefslogtreecommitdiffstats
path: root/mm/gup.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-03 07:27:16 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-03 07:27:16 +0200
commit23004ec330925e6834c8ddac00e3dd12eb5fb345 (patch)
tree6bcbf18d8a2429e16f842b8a357f439f4f8d3926 /mm/gup.c
parent4c1d2fc7d56cf87a0d399be69e08d5aef73802eb (diff)
parentf2c7c76c5d0a443053e94adb9f0918fa2fb85c3a (diff)
downloadlinux-stable-23004ec330925e6834c8ddac00e3dd12eb5fb345.tar.gz
linux-stable-23004ec330925e6834c8ddac00e3dd12eb5fb345.tar.bz2
linux-stable-23004ec330925e6834c8ddac00e3dd12eb5fb345.zip
Merge 5.2-rc3 into staging-next
We need the staging fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm/gup.c')
-rw-r--r--mm/gup.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/mm/gup.c b/mm/gup.c
index 2c08248d4fa2..ddde097cf9e4 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-only
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/err.h>
@@ -1041,10 +1042,6 @@ static __always_inline long __get_user_pages_locked(struct task_struct *tsk,
BUG_ON(ret >= nr_pages);
}
- if (!pages)
- /* If it's a prefault don't insist harder */
- return ret;
-
if (ret > 0) {
nr_pages -= ret;
pages_done += ret;
@@ -1060,8 +1057,12 @@ static __always_inline long __get_user_pages_locked(struct task_struct *tsk,
pages_done = ret;
break;
}
- /* VM_FAULT_RETRY triggered, so seek to the faulting offset */
- pages += ret;
+ /*
+ * VM_FAULT_RETRY triggered, so seek to the faulting offset.
+ * For the prefault case (!pages) we only update counts.
+ */
+ if (likely(pages))
+ pages += ret;
start += ret << PAGE_SHIFT;
/*
@@ -1084,7 +1085,8 @@ static __always_inline long __get_user_pages_locked(struct task_struct *tsk,
pages_done++;
if (!nr_pages)
break;
- pages++;
+ if (likely(pages))
+ pages++;
start += PAGE_SIZE;
}
if (lock_dropped && *locked) {