On Sat, 1 Aug 2020 17:08:26 +0800 Wenchao Hao <haowenchao22@xxxxxxxxx> wrote: > Previous implement called untagged_addr before error check, while > if the error check failed and return EINVAL, the untagged_addr is > just useless work. > > ... > > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -1632,11 +1632,11 @@ static int kernel_get_mempolicy(int __user *policy, > int uninitialized_var(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) Well, the compiler will surely avoid that useless work. But the code is better this way.