diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index dc49e41e1a14..41d60c214a07 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -9085,8 +9085,6 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id, int ret = 0; *out_count = 0; - if (in_count == 0) - return -EINVAL; start = le64_to_cpu(qar_req->file_offset); length = le64_to_cpu(qar_req->length); @@ -9098,8 +9096,18 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id, if (!fp) return -ENOENT; - ret = ksmbd_vfs_fqar_lseek(fp, start, length, - qar_rsp, in_count, out_count); + if (!in_count) { + struct file_allocated_range_buffer range; + + ret = ksmbd_vfs_fqar_lseek(fp, start, length, &range, 1, + out_count); + if (!ret && *out_count) + ret = -ENOSPC; + *out_count = 0; + } else { + ret = ksmbd_vfs_fqar_lseek(fp, start, length, + qar_rsp, in_count, out_count); + } if (ret && ret != -E2BIG) *out_count = 0;