]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blobdiff - lib/strnlen_user.c
khugepaged: collapse_pte_mapped_thp() protect the pmd lock
[mirror_ubuntu-focal-kernel.git] / lib / strnlen_user.c
index 6c0005d5dd5c43e7ed4097c24d5fc785a794110e..41670d4a5816530d7b948fe29f0fad20a44ec2ed 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();