]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
block: bio_iov_iter_get_pages: fix size of last iovec
authorMartin Wilck <mwilck@suse.com>
Wed, 25 Jul 2018 21:15:07 +0000 (23:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Aug 2018 05:48:02 +0000 (07:48 +0200)
commitc08cdf9b5ffdbeed136b171afa35771c7ffba4f7
tree938e39742a15d800364bd2d9ed3c3cef3749bfb8
parent09e3b44aeaac9e0fe575ba17d360fd4803382d02
block: bio_iov_iter_get_pages: fix size of last iovec

commit b403ea2404889e1227812fa9657667a1deb9c694 upstream.

If the last page of the bio is not "full", the length of the last
vector slot needs to be corrected. This slot has the index
(bio->bi_vcnt - 1), but only in bio->bi_io_vec. In the "bv" helper
array, which is shifted by the value of bio->bi_vcnt at function
invocation, the correct index is (nr_pages - 1).

v2: improved readability following suggestions from Ming Lei.
v3: followed a formatting suggestion from Christoph Hellwig.

Fixes: 2cefe4dbaadf ("block: add bio_iov_iter_get_pages()")
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
block/bio.c