]> git.dujemihanovic.xyz Git - linux.git/commitdiff
mm/mempolicy.c: check parameters first in kernel_get_mempolicy
authorWenchao Hao <haowenchao22@gmail.com>
Wed, 12 Aug 2020 01:31:16 +0000 (18:31 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 12 Aug 2020 17:57:56 +0000 (10:57 -0700)
Previous implementatoin calls untagged_addr() before error check, while if
the error check failed and return EINVAL, the untagged_addr() call is just
useless work.

Signed-off-by: Wenchao Hao <haowenchao22@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20200801090825.5597-1-haowenchao22@gmail.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/mempolicy.c

index 92030ead25064dce87185a0a67a6a06651002427..25b7e412c20b437640d4e849e89129480aa20c57 100644 (file)
@@ -1632,11 +1632,11 @@ static int kernel_get_mempolicy(int __user *policy,
        int pval;
        nodemask_t nodes;
 
-       addr = untagged_addr(addr);
-
        if (nmask != NULL && maxnode < nr_node_ids)
                return -EINVAL;
 
+       addr = untagged_addr(addr);
+
        err = do_get_mempolicy(&pval, &nodes, addr, flags);
 
        if (err)