On Sun 09-11-25 06:37:34, Al Viro wrote: > Convert the user_path_at() call inside a retry loop into getname_flags() + > filename_lookup() + putname() and leave only filename_lookup() inside > the loop. > > Since we have the default logics for use of LOOKUP_EMPTY (passed iff > AT_EMPTY_PATH is present in flags), just use getname_uflags() and > don't bother with setting LOOKUP_EMPTY in lookup_flags - getname_uflags() > will pass the right thing to getname_flags() and filename_lookup() > doesn't care about LOOKUP_EMPTY at all. > > The things could be further simplified by use of cleanup.h stuff, but > let's not clutter the patch with that. > > Signed-off-by: Al Viro <[email protected]>
Looks good. Feel free to add: Reviewed-by: Jan Kara <[email protected]> Honza > --- > fs/open.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fs/open.c b/fs/open.c > index db8fe2b5463d..e9a08a820e49 100644 > --- a/fs/open.c > +++ b/fs/open.c > @@ -682,6 +682,7 @@ static int do_fchmodat(int dfd, const char __user > *filename, umode_t mode, > unsigned int flags) > { > struct path path; > + struct filename *name; > int error; > unsigned int lookup_flags; > > @@ -689,11 +690,9 @@ static int do_fchmodat(int dfd, const char __user > *filename, umode_t mode, > return -EINVAL; > > lookup_flags = (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; > - if (flags & AT_EMPTY_PATH) > - lookup_flags |= LOOKUP_EMPTY; > - > + name = getname_uflags(filename, flags); > retry: > - error = user_path_at(dfd, filename, lookup_flags, &path); > + error = filename_lookup(dfd, name, lookup_flags, &path, NULL); > if (!error) { > error = chmod_common(&path, mode); > path_put(&path); > @@ -702,6 +701,7 @@ static int do_fchmodat(int dfd, const char __user > *filename, umode_t mode, > goto retry; > } > } > + putname(name); > return error; > } > > -- > 2.47.3 > -- Jan Kara <[email protected]> SUSE Labs, CR
