diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-10-08 21:47:44 (GMT) |
---|---|---|
committer | Mike Marshall <hubcap@omnibond.com> | 2015-11-13 15:57:53 (GMT) |
commit | 34204fde4c877cb33d8ec0df09f38333f570cc84 (patch) | |
tree | f5ccfef4968e45e9d3432556b17805e02a8b660e /fs | |
parent | 5c278228bbfe3abb7d468ef39dffac23de15c078 (diff) | |
download | linux-34204fde4c877cb33d8ec0df09f38333f570cc84.tar.xz |
pvfs_bufmap_copy_from_iovec(): don't rely upon size being equal to iov_iter_count(iter)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/orangefs/pvfs2-bufmap.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/fs/orangefs/pvfs2-bufmap.c b/fs/orangefs/pvfs2-bufmap.c index 8438830..dacf42b 100644 --- a/fs/orangefs/pvfs2-bufmap.c +++ b/fs/orangefs/pvfs2-bufmap.c @@ -512,26 +512,25 @@ int pvfs_bufmap_copy_from_iovec(struct pvfs2_bufmap *bufmap, int buffer_index, size_t size) { - struct pvfs_bufmap_desc *to; - struct page *page; - size_t copied; + struct pvfs_bufmap_desc *to = &bufmap->desc_array[buffer_index]; int i; gossip_debug(GOSSIP_BUFMAP_DEBUG, - "%s: buffer_index:%d: size:%lu:\n", + "%s: buffer_index:%d: size:%zu:\n", __func__, buffer_index, size); - to = &bufmap->desc_array[buffer_index]; for (i = 0; size; i++) { - page = to->page_array[i]; - copied = copy_page_from_iter(page, 0, PAGE_SIZE, iter); - size -= copied; - if ((copied == 0) && (size)) - break; + struct page *page = to->page_array[i]; + size_t n = size; + if (n > PAGE_SIZE) + n = PAGE_SIZE; + n = copy_page_from_iter(page, 0, n, iter); + if (!n) + return -EFAULT; + size -= n; } - - return size ? -EFAULT : 0; + return 0; } |