stat: use vfs_empty_path() helper
authorChristian Brauner <brauner@kernel.org>
Tue, 30 Apr 2024 11:57:58 +0000 (13:57 +0200)
committerChristian Brauner <brauner@kernel.org>
Thu, 27 Jun 2024 16:31:20 +0000 (18:31 +0200)
Use the newly added helper for this.

Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/stat.c

index 16aa1f5ceec4195b566c48f40d2858687b50e587..5039c34a385d7338953eb91814da3bb6d57b55c6 100644 (file)
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -289,16 +289,8 @@ int vfs_fstatat(int dfd, const char __user *filename,
         * If AT_EMPTY_PATH is set, we expect the common case to be that
         * empty path, and avoid doing all the extra pathname work.
         */
-       if (dfd >= 0 && flags == AT_EMPTY_PATH) {
-               char c;
-
-               ret = get_user(c, filename);
-               if (unlikely(ret))
-                       return ret;
-
-               if (likely(!c))
-                       return vfs_fstat(dfd, stat);
-       }
+       if (flags == AT_EMPTY_PATH && vfs_empty_path(dfd, filename))
+               return vfs_fstat(dfd, stat);
 
        name = getname_flags(filename, getname_statx_lookup_flags(statx_flags));
        ret = vfs_statx(dfd, name, statx_flags, stat, STATX_BASIC_STATS);