blob: 33ffb5f07831b7705433ec18ae6bc28d62213dea [file] [log] [blame]
From 73c38d110c60e726b4537d7e91279682188a5157 Mon Sep 17 00:00:00 2001
From: Murphy Zhou <>
Date: Sat, 14 Mar 2020 11:38:31 +0800
Subject: [PATCH] CIFS: fiemap: do not return EINVAL if get nothing
commit 979a2665eb6c603ddce0ab374041ab101827b2e7 upstream.
If we call fiemap on a truncated file with none blocks allocated,
it makes sense we get nothing from this call. No output means
no blocks have been counted, but the call succeeded. It's a valid
Simple example reproducer:
xfs_io -f 'truncate 2M' -c 'fiemap -v' /cifssch/testfile
xfs_io: ioctl(FS_IOC_FIEMAP) ["/cifssch/testfile"]: Invalid argument
Signed-off-by: Murphy Zhou <>
Signed-off-by: Steve French <>
Reviewed-by: Pavel Shilovsky <>
CC: Stable <>
Signed-off-by: Paul Gortmaker <>
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 597d50d23fbe..b5022a099ae6 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -3172,7 +3172,7 @@ static int smb3_fiemap(struct cifs_tcon *tcon,
if (rc)
goto out;
- if (out_data_len < sizeof(struct file_allocated_range_buffer)) {
+ if (out_data_len && out_data_len < sizeof(struct file_allocated_range_buffer)) {
rc = -EINVAL;
goto out;