Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-2.6-microblaze.git] / lib / strnlen_user.c
index 6c0005d..41670d4 100644 (file)
@@ -26,13 +26,6 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count,
        unsigned long align, res = 0;
        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..
@@ -109,6 +102,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();