]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
user_statfs(): import pathname only once
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 1 Nov 2025 04:48:31 +0000 (00:48 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 13 Jan 2026 20:16:44 +0000 (15:16 -0500)
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 <viro@zeniv.linux.org.uk>
fs/statfs.c

index a45ac85e6048681c726b61a8b06ed516617cd916..a5671bf6c7f03a73d8d3e38142bb560cd376474a 100644 (file)
@@ -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 @@ retry:
                        goto retry;
                }
        }
+       putname(name);
        return error;
 }