linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Wenchao Hao <haowenchao22@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm, mempolicy: Check parameters first in kernel_get_mempolicy
Date: Mon, 3 Aug 2020 20:25:16 -0700	[thread overview]
Message-ID: <20200803202516.5d6c1c770137cb35a288f514@linux-foundation.org> (raw)
In-Reply-To: <20200801090825.5597-1-haowenchao22@gmail.com>

On Sat,  1 Aug 2020 17:08:26 +0800 Wenchao Hao <haowenchao22@gmail.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.



      reply	other threads:[~2020-08-04  3:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-01  9:08 [PATCH] mm, mempolicy: Check parameters first in kernel_get_mempolicy Wenchao Hao
2020-08-04  3:25 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200803202516.5d6c1c770137cb35a288f514@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=haowenchao22@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).