diff mbox series

[v5.4-v4.19,5/6] stat: use vfs_empty_path() helper

Message ID 20240918-statx-stable-linux-5-4-y-v1-5-8a771c9bbe5f@gmail.com (mailing list archive)
State New
Headers show
Series Backport statx(..., NULL, AT_EMPTY_PATH, ...) | expand

Commit Message

Miao Wang via B4 Relay Sept. 18, 2024, 2:12 p.m. UTC
From: Christian Brauner <brauner@kernel.org>

commit 27a2d0c upstream.

Use the newly added helper for this.

Signed-off-by: Christian Brauner <brauner@kernel.org>

Cc: <stable@vger.kernel.org> # 4.19.x-5.4.x
Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
Tested-by: Xi Ruoyao <xry111@xry111.site>
---
 fs/stat.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/fs/stat.c b/fs/stat.c
index 3ae958308e48..1aaa5d847db8 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -224,16 +224,9 @@  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;
+	if (flags == AT_EMPTY_PATH && vfs_empty_path(dfd, filename))
+		return vfs_fstat(dfd, stat);
 
-		ret = get_user(c, filename);
-		if (unlikely(ret))
-			return ret;
-
-		if (likely(!c))
-			return vfs_fstat(dfd, stat);
-	}
 	return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT,
 			 stat, STATX_BASIC_STATS);
 }