[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20200803202516.5d6c1c770137cb35a288f514@linux-foundation.org>
Date: Mon, 3 Aug 2020 20:25:16 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Wenchao Hao <haowenchao22@...il.com>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm, mempolicy: Check parameters first in
kernel_get_mempolicy
On Sat, 1 Aug 2020 17:08:26 +0800 Wenchao Hao <haowenchao22@...il.com> 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.
Powered by blists - more mailing lists