Commit 91ef658f authored by Dmitry Kadashev's avatar Dmitry Kadashev Committed by Jens Axboe

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: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/io-uring/CAHk-=wgCac9hBsYzKMpHk0EbLgQaXR=OUAjHaBtaY+G8A9KhFg@mail.gmail.com/Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: default avatarDmitry Kadashev <dkadashev@gmail.com>
Link: https://lore.kernel.org/r/20210708063447.3556403-2-dkadashev@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 26578cda
...@@ -247,6 +247,9 @@ getname_kernel(const char * filename) ...@@ -247,6 +247,9 @@ getname_kernel(const char * filename)
void putname(struct filename *name) void putname(struct filename *name)
{ {
if (IS_ERR_OR_NULL(name))
return;
BUG_ON(name->refcnt <= 0); BUG_ON(name->refcnt <= 0);
if (--name->refcnt > 0) if (--name->refcnt > 0)
...@@ -4728,11 +4731,9 @@ int do_renameat2(int olddfd, struct filename *from, int newdfd, ...@@ -4728,11 +4731,9 @@ int do_renameat2(int olddfd, struct filename *from, int newdfd,
goto retry; goto retry;
} }
put_both: put_both:
if (!IS_ERR(from)) putname(from);
putname(from);
put_new: put_new:
if (!IS_ERR(to)) putname(to);
putname(to);
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment