Skip to content

Commit

Permalink
iov_iter_get_pages(): sanity-check arguments
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Aug 9, 2022
1 parent 9132955 commit c81ce28
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/iov_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c81ce28

Please sign in to comment.