From: Kaitao Cheng <pilgrimtao@gmail.com>
To: adobriyan@gmail.com
Cc: christian@brauner.io, ebiederm@xmission.com,
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,
Kaitao Cheng <pilgrimtao@gmail.com>
Subject: [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink.
Date: Wed, 27 May 2020 22:11:55 +0800 [thread overview]
Message-ID: <20200527141155.47554-1-pilgrimtao@gmail.com> (raw)
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)){}.
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)
--
2.20.1
next reply other threads:[~2020-05-27 14:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-27 14:11 Kaitao Cheng [this message]
2020-05-27 14:41 ` [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink Eric W. Biederman
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=20200527141155.47554-1-pilgrimtao@gmail.com \
--to=pilgrimtao@gmail.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@gmail.com \
--cc=christian@brauner.io \
--cc=ebiederm@xmission.com \
--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=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