block: don't run get_page() on pages from non-bvec iov iter
authorMing Lei <ming.lei@redhat.com>
Wed, 24 Apr 2019 11:01:46 +0000 (19:01 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 24 Apr 2019 14:06:04 +0000 (08:06 -0600)
The refcount has been increased for pages retrieved from non-bvec iov iter
via __bio_iov_iter_get_pages(), so don't need to do that again.

Otherwise, IO pages are leaked easily.

Cc: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Fixes: 7321ecbfc7cf ("block: change how we get page references in bio_iov_iter_get_pages")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c

index c81ed2dfee530bf33b7382da6cc6c2ab3c0ed031..662d45752ec53505a787cff4e9e97d2bf0a808dc 100644 (file)
@@ -992,7 +992,7 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
 
        if (iov_iter_bvec_no_ref(iter))
                bio_set_flag(bio, BIO_NO_PAGE_REF);
-       else
+       else if (is_bvec)
                bio_get_pages(bio);
 
        return bio->bi_vcnt ? 0 : ret;