diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2022-06-17 21:15:14 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2022-08-09 04:37:20 +0200 |
commit | c81ce28df500b04444ef97dc82a7b0299ce717e8 (patch) | |
tree | e7987013cb4c73a500219d7d80eda6b692b030ad /lib | |
parent | iov_iter_get_pages_alloc(): lift freeing pages array on failure exits into wr... (diff) | |
download | linux-c81ce28df500b04444ef97dc82a7b0299ce717e8.tar.xz linux-c81ce28df500b04444ef97dc82a7b0299ce717e8.zip |
iov_iter_get_pages(): sanity-check arguments
zero maxpages is bogus, but best treated as "just return 0";
NULL pages, OTOH, should be treated as a hard bug.
get rid of now completely useless checks in xarray_get_pages{,_alloc}().
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/iov_iter.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c index e14749711e34..7d3158d1f8ea 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1368,9 +1368,6 @@ static ssize_t iter_xarray_get_pages(struct iov_iter *i, size_t size = maxsize; loff_t pos; - if (!size || !maxpages) - return 0; - pos = i->xarray_start + i->iov_offset; index = pos >> PAGE_SHIFT; offset = pos & ~PAGE_MASK; @@ -1440,10 +1437,11 @@ ssize_t iov_iter_get_pages(struct iov_iter *i, if (maxsize > i->count) maxsize = i->count; - if (!maxsize) + if (!maxsize || !maxpages) return 0; if (maxsize > MAX_RW_COUNT) maxsize = MAX_RW_COUNT; + BUG_ON(!pages); if (likely(user_backed_iter(i))) { unsigned int gup_flags = 0; @@ -1522,9 +1520,6 @@ static ssize_t iter_xarray_get_pages_alloc(struct iov_iter *i, size_t size = maxsize; loff_t pos; - if (!size) - return 0; - pos = i->xarray_start + i->iov_offset; index = pos >> PAGE_SHIFT; offset = pos & ~PAGE_MASK; |