From: Murphy Zhou Date: Sat, 14 Mar 2020 03:38:31 +0000 (+0800) Subject: CIFS: fiemap: do not return EINVAL if get nothing X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f5be2f69e89613c409f89f6429bd210efcb147b;p=linux 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 response. 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: Greg Kroah-Hartman --- diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 99420608d2ec5..76eacffb24d86 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -3252,7 +3252,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; }