Re: [RFC][PATCH 07/13] user_statfs(): 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 <emxajufuojjhec3afuqopsvl5ysogkxnwtskfoxj5tw2tqobup@4gvrhzrkdk2x>
On Sun 09-11-25 06:37:39, 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.
> 
> In this case we never pass LOOKUP_EMPTY, so getname_flags() is equivalent
> to plain getname().
> 
> 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/statfs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/statfs.c b/fs/statfs.c
> index a45ac85e6048..a5671bf6c7f0 100644
> --- a/fs/statfs.c
> +++ b/fs/statfs.c
> @@ -99,8 +99,9 @@ int user_statfs(const char __user *pathname, struct kstatfs *st)
>  	struct path path;
>  	int error;
>  	unsigned int lookup_flags = LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT;
> +	struct filename *name = getname(pathname);
>  retry:
> -	error = user_path_at(AT_FDCWD, pathname, lookup_flags, &path);
> +	error = filename_lookup(AT_FDCWD, name, lookup_flags, &path, NULL);
>  	if (!error) {
>  		error = vfs_statfs(&path, st);
>  		path_put(&path);
> @@ -109,6 +110,7 @@ int user_statfs(const char __user *pathname, struct kstatfs *st)
>  			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.