public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Kaitao Cheng <pilgrimtao@gmail.com>
Cc: adobriyan@gmail.com, christian@brauner.io,
	akpm@linux-foundation.org, gladkov.alexey@gmail.com, guro@fb.com,
	walken@google.com, avagin@gmail.com, khlebnikov@yandex-team.ru,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink.
Date: Wed, 27 May 2020 09:41:53 -0500	[thread overview]
Message-ID: <87k10x5tji.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <20200527141155.47554-1-pilgrimtao@gmail.com> (Kaitao Cheng's message of "Wed, 27 May 2020 22:11:55 +0800")

Kaitao Cheng <pilgrimtao@gmail.com> writes:

> we don't need {len = PTR_ERR(pathname)} when IS_ERR(pathname) is false,
> it's better to move it into if(IS_ERR(pathname)){}.

Please look at the generated code.

I believe you will find that your change will generate worse assembly.

Eric


> Signed-off-by: Kaitao Cheng <pilgrimtao@gmail.com>
> ---
>  fs/proc/base.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index d86c0afc8a85..9509e0d42610 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1753,9 +1753,10 @@ static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
>  		return -ENOMEM;
>  
>  	pathname = d_path(path, tmp, PAGE_SIZE);
> -	len = PTR_ERR(pathname);
> -	if (IS_ERR(pathname))
> +	if (IS_ERR(pathname)) {
> +		len = PTR_ERR(pathname);
>  		goto out;
> +	}
>  	len = tmp + PAGE_SIZE - 1 - pathname;
>  
>  	if (len > buflen)

  reply	other threads:[~2020-05-27 14:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27 14:11 [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink Kaitao Cheng
2020-05-27 14:41 ` Eric W. Biederman [this message]
2020-05-27 15:23   ` Alexey Dobriyan
2020-05-27 16:36     ` Eric W. Biederman

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=87k10x5tji.fsf@x220.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=avagin@gmail.com \
    --cc=christian@brauner.io \
    --cc=gladkov.alexey@gmail.com \
    --cc=guro@fb.com \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pilgrimtao@gmail.com \
    --cc=walken@google.com \
    /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