summaryrefslogtreecommitdiff
path: root/lib/iov_iter.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2021-04-27 12:34:04 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2021-06-03 10:36:51 -0400
commita506abc7b644d71966a75337d5a534f531b3cdc4 (patch)
treef5a2e285bc2be4d018eb988d90228a414974f997 /lib/iov_iter.c
parent08aa64796016cb47b2ef3d0924653b4d944b0d65 (diff)
copy_page_to_iter(): fix ITER_DISCARD case
we need to advance the iterator... Cc: stable@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'lib/iov_iter.c')
-rw-r--r--lib/iov_iter.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 12fb04b23143..c8877cffb7bc 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -965,9 +965,12 @@ static size_t __copy_page_to_iter(struct page *page, size_t offset, size_t bytes
size_t wanted = copy_to_iter(kaddr + offset, bytes, i);
kunmap_atomic(kaddr);
return wanted;
- } else if (unlikely(iov_iter_is_discard(i)))
+ } else if (unlikely(iov_iter_is_discard(i))) {
+ if (unlikely(i->count < bytes))
+ bytes = i->count;
+ i->count -= bytes;
return bytes;
- else if (likely(!iov_iter_is_pipe(i)))
+ } else if (likely(!iov_iter_is_pipe(i)))
return copy_page_to_iter_iovec(page, offset, bytes, i);
else
return copy_page_to_iter_pipe(page, offset, bytes, i);