]> git.baikalelectronics.ru Git - kernel.git/commit
iov_iter: Fix iov_iter_get_pages{,_alloc} page fault return value
authorAndreas Gruenbacher <agruenba@redhat.com>
Wed, 21 Jul 2021 17:03:47 +0000 (19:03 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Tue, 12 Oct 2021 16:13:36 +0000 (18:13 +0200)
commit0f8492be31f21f9da3ce2981461e58c3aa06fd3d
tree547ae6c7ab81349b8b5f3f1200f337c1853378ac
parent9ca0986666178f71c70ba0652ce4f64d53ea42de
iov_iter: Fix iov_iter_get_pages{,_alloc} page fault return value

Both iov_iter_get_pages and iov_iter_get_pages_alloc return the number
of bytes of the iovec they could get the pages for.  When they cannot
get any pages, they're supposed to return 0, but when the start of the
iovec isn't page aligned, the calculation goes wrong and they return a
negative value.  Fix both functions.

In addition, change iov_iter_get_pages_alloc to return NULL in that case
to prevent resource leaks.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
lib/iov_iter.c