public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] proc/base: Skip assignment to len when there is no error on d_path in do_proc_readlink.
@ 2020-05-27 14:11 Kaitao Cheng
  2020-05-27 14:41 ` Eric W. Biederman
  0 siblings, 1 reply; 4+ messages in thread
From: Kaitao Cheng @ 2020-05-27 14:11 UTC (permalink / raw)
  To: adobriyan
  Cc: christian, ebiederm, akpm, gladkov.alexey, guro, walken, avagin,
	khlebnikov, linux-kernel, linux-fsdevel, Kaitao Cheng

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-27 16:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2020-05-27 15:23   ` Alexey Dobriyan
2020-05-27 16:36     ` Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox