Message ID | 7d880675-4aba-4081-84af-1cbacaef17ab@sandeen.net (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | exfat: short-circuit zero-byte writes in exfat_file_write_iter | expand |
Please add the "Fixes" tag. Fixes: 11a347fb6cef ("exfat: change to get file size from DataLength")
On Wed, Feb 12, 2025 at 3:37 PM Yuezhang.Mo@sony.com <Yuezhang.Mo@sony.com> wrote: > > Please add the "Fixes" tag. > > Fixes: 11a347fb6cef ("exfat: change to get file size from DataLength") I have directly added and applied it to #dev. Thanks!
diff --git a/fs/exfat/file.c b/fs/exfat/file.c index 05b51e721783..807349d8ea05 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -587,7 +587,7 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter) valid_size = ei->valid_size; ret = generic_write_checks(iocb, iter); - if (ret < 0) + if (ret <= 0) goto unlock; if (iocb->ki_flags & IOCB_DIRECT) {
When generic_write_checks() returns zero, it means that iov_iter_count() is zero, and there is no work to do. Simply return success like all other filesystems do, rather than proceeding down the write path, which today yields an -EFAULT in generic_perform_write() via the (fault_in_iov_iter_readable(i, bytes) == bytes) check when bytes == 0. Reported-by: Noah <kernel-org-10@maxgrass.eu> Signed-off-by: Eric Sandeen <sandeen@redhat.com> ---