Re: [RFC][PATCH 09/13] do_readlinkat(): import pathname only once

Jan Kara <[email protected]>
Newsgroups org.kernel.vger.audit,org.kernel.vger.io-uring,org.kernel.vger.linux-fsdevel
Message-ID <ynfg5hg2ndye7f4d2crubmwq5br7rzi2pn3ka6vqsd7ndihzke@jnf743scaayv>
On Sun 09-11-25 06:37:41, Al Viro wrote:
> Take getname_flags() and putname() outside of retry loop.
> 
> Since getname_flags() is the only thing that cares about LOOKUP_EMPTY,
> don't bother with setting LOOKUP_EMPTY in lookup_flags - just pass it
> to getname_flags() and be done with that.
> 
> 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/stat.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/stat.c b/fs/stat.c
> index 6c79661e1b96..ee9ae2c3273a 100644
> --- a/fs/stat.c
> +++ b/fs/stat.c
> @@ -566,13 +566,13 @@ static int do_readlinkat(int dfd, const char __user *pathname,
>  	struct path path;
>  	struct filename *name;
>  	int error;
> -	unsigned int lookup_flags = LOOKUP_EMPTY;
> +	unsigned int lookup_flags = 0;
>  
>  	if (bufsiz <= 0)
>  		return -EINVAL;
>  
> +	name = getname_flags(pathname, LOOKUP_EMPTY);
>  retry:
> -	name = getname_flags(pathname, lookup_flags);
>  	error = filename_lookup(dfd, name, lookup_flags, &path, NULL);
>  	if (unlikely(error)) {
>  		putname(name);
> @@ -593,11 +593,11 @@ static int do_readlinkat(int dfd, const char __user *pathname,
>  		error = (name->name[0] == '\0') ? -ENOENT : -EINVAL;
>  	}
>  	path_put(&path);
> -	putname(name);
>  	if (retry_estale(error, lookup_flags)) {
>  		lookup_flags |= LOOKUP_REVAL;
>  		goto retry;
>  	}
> +	putname(name);
>  	return error;
>  }
>  
> -- 
> 2.47.3
> 
-- 
Jan Kara <[email protected]>
SUSE Labs, CR
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.