Skip to content

Commit 42c498c

Browse files
author
Andreas Gruenbacher
committed
iomap: Fix iomap_dio_rw return value for user copies
When a user copy fails in one of the helpers of iomap_dio_rw, fail with -EFAULT instead of returning 0. This matches what iomap_dio_bio_actor returns when it gets an -EFAULT from bio_iov_iter_get_pages. With these changes, iomap_dio_actor now consistently fails with -EFAULT when a user page cannot be faulted in. Signed-off-by: Andreas Gruenbacher <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 00bfe02 commit 42c498c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/iomap/direct-io.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ static loff_t iomap_dio_hole_iter(const struct iomap_iter *iter,
371371
loff_t length = iov_iter_zero(iomap_length(iter), dio->submit.iter);
372372

373373
dio->size += length;
374+
if (!length)
375+
return -EFAULT;
374376
return length;
375377
}
376378

@@ -402,6 +404,8 @@ static loff_t iomap_dio_inline_iter(const struct iomap_iter *iomi,
402404
copied = copy_to_iter(inline_data, length, iter);
403405
}
404406
dio->size += copied;
407+
if (!copied)
408+
return -EFAULT;
405409
return copied;
406410
}
407411

0 commit comments

Comments
 (0)