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>
This commit is contained in:
parent
26578cda3d
commit
91ef658fb8
@ -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 @@ exit1:
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user