From e5ca024e165d952b12da5ea86c36ea70d70bfc98 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 7 Jan 2022 12:20:37 -0500 Subject: fs/namei.c:reserve_stack(): tidy up the call of try_to_unlazy() !foo() != 0 is a strange way to spell !foo(); fallout from "fs: make unlazy_walk() error handling consistent"... Signed-off-by: Al Viro --- fs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/namei.c') diff --git a/fs/namei.c b/fs/namei.c index 3f1829b3ab5b..9e327d0717d0 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1754,7 +1754,7 @@ static int reserve_stack(struct nameidata *nd, struct path *link, unsigned seq) // unlazy even if we fail to grab the link - cleanup needs it bool grabbed_link = legitimize_path(nd, link, seq); - if (!try_to_unlazy(nd) != 0 || !grabbed_link) + if (!try_to_unlazy(nd) || !grabbed_link) return -ECHILD; if (nd_alloc_stack(nd)) -- cgit v1.2.3 From 52dba645ca3a2e8695f14fefb608a3b82a7c8a4e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 7 Jan 2022 12:24:41 -0500 Subject: get rid of dead code in legitimize_root() Combination of LOOKUP_IS_SCOPED and NULL nd->root.mnt is impossible after successful path_init(). All places where ->root.mnt might become NULL do that only if LOOKUP_IS_SCOPED is not there and path_init() itself can return success without setting nd->root only if ND_ROOT_PRESET had been set (in which case nd->root had been set by caller and never changed) or if the name had been a relative one *and* none of the bits in LOOKUP_IS_SCOPED had been present. Since all calls of legitimize_root() must be downstream of successful path_init(), the check for !nd->root.mnt && (nd->flags & LOOKUP_IS_SCOPED) is pure paranoia. FWIW, it had been discussed (and agreed upon) with Aleksa back when scoped lookups had been merged; looks like that had fallen through the cracks back then. Signed-off-by: Al Viro --- fs/namei.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'fs/namei.c') diff --git a/fs/namei.c b/fs/namei.c index 9e327d0717d0..69e6ba7c407b 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -729,13 +729,6 @@ static bool legitimize_links(struct nameidata *nd) static bool legitimize_root(struct nameidata *nd) { - /* - * For scoped-lookups (where nd->root has been zeroed), we need to - * restart the whole lookup from scratch -- because set_root() is wrong - * for these lookups (nd->dfd is the root, not the filesystem root). - */ - if (!nd->root.mnt && (nd->flags & LOOKUP_IS_SCOPED)) - return false; /* Nothing to do if nd->root is zero or is managed by the VFS user. */ if (!nd->root.mnt || (nd->state & ND_ROOT_PRESET)) return true; -- cgit v1.2.3 From 30476f7e6dbcb075850c6e33b15460dd4868c985 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Tue, 25 Jan 2022 05:13:40 -0800 Subject: namei: cleanup double word in comment Remove the second 'to'. Signed-off-by: Tom Rix Signed-off-by: Al Viro --- fs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/namei.c') diff --git a/fs/namei.c b/fs/namei.c index 69e6ba7c407b..486394624853 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -790,7 +790,7 @@ out: * @seq: seq number to check @dentry against * Returns: true on success, false on failure * - * Similar to to try_to_unlazy(), but here we have the next dentry already + * Similar to try_to_unlazy(), but here we have the next dentry already * picked by rcu-walk and want to legitimize that in addition to the current * nd->path and nd->root for ref-walk mode. Must be called from rcu-walk context. * Nothing should touch nameidata between try_to_unlazy_next() failure and -- cgit v1.2.3