aboutsummaryrefslogtreecommitdiffstats
path: root/lib/strnlen_user.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/strnlen_user.c')
-rw-r--r--lib/strnlen_user.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
index 7f2db3fe311f..069fc8e463d0 100644
--- a/lib/strnlen_user.c
+++ b/lib/strnlen_user.c
@@ -32,13 +32,6 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count,
unsigned long c;
/*
- * Truncate 'max' to the user-specified limit, so that
- * we only have one limit we need to check in the loop
- */
- if (max > count)
- max = count;
-
- /*
* Do everything aligned. But that means that we
* need to also expand the maximum..
*/
@@ -114,6 +107,13 @@ long strnlen_user(const char __user *str, long count)
unsigned long max = max_addr - src_addr;
long retval;
+ /*
+ * Truncate 'max' to the user-specified limit, so that
+ * we only have one limit we need to check in the loop
+ */
+ if (max > count)
+ max = count;
+
if (user_access_begin(str, max)) {
retval = do_strnlen_user(str, count, max);
user_access_end();