diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2021-04-27 12:34:04 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-07-14 17:06:06 +0200 |
commit | 64c430ea07a40dba6a277f3e9518d174269d1542 (patch) | |
tree | 839d48dc61808539ebb761b18258739c60022f01 /lib | |
parent | baf1972e79010cff444a9d08f1e744686858cec8 (diff) | |
download | linux-stable-64c430ea07a40dba6a277f3e9518d174269d1542.tar.gz linux-stable-64c430ea07a40dba6a277f3e9518d174269d1542.tar.bz2 linux-stable-64c430ea07a40dba6a277f3e9518d174269d1542.zip |
copy_page_to_iter(): fix ITER_DISCARD case
commit a506abc7b644d71966a75337d5a534f531b3cdc4 upstream.
we need to advance the iterator...
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/iov_iter.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c index c701b7a187f2..0ce968a0060b 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -967,9 +967,12 @@ 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); |