summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kadashev <dkadashev@gmail.com>2021-07-08 13:34:37 +0700
committerJens Axboe <axboe@kernel.dk>2021-08-23 13:41:26 -0600
commit91ef658fb8b82837f94ea0d45d14b5b2d2541e70 (patch)
treeb1ced52aaffc27fb1b6ff4677c5d896ea4847ae5
parent26578cda3db983b17cabe4e577af26306beb9987 (diff)
namei: ignore ERR/NULL names in putname()
Supporting ERR/NULL names in putname() makes callers code cleaner, and is what some other path walking functions already support for the same reason. This also removes a few existing IS_ERR checks before putname(). Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/io-uring/CAHk-=wgCac9hBsYzKMpHk0EbLgQaXR=OUAjHaBtaY+G8A9KhFg@mail.gmail.com/ Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christian Brauner <christian.brauner@ubuntu.com> Signed-off-by: Dmitry Kadashev <dkadashev@gmail.com> Link: https://lore.kernel.org/r/20210708063447.3556403-2-dkadashev@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--fs/namei.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/namei.c b/fs/namei.c
index bf6d8a738c59..dc36bda5c2e7 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -247,6 +247,9 @@ getname_kernel(const char * filename)
void putname(struct filename *name)
{
+ if (IS_ERR_OR_NULL(name))
+ return;
+
BUG_ON(name->refcnt <= 0);
if (--name->refcnt > 0)
@@ -4728,11 +4731,9 @@ exit1:
goto retry;
}
put_both:
- if (!IS_ERR(from))
- putname(from);
+ putname(from);
put_new:
- if (!IS_ERR(to))
- putname(to);
+ putname(to);
return error;
}