]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
block: don't initialize bi_vcnt for cloned bio in bio_iov_bvec_set()
authorMing Lei <ming.lei@redhat.com>
Wed, 31 Dec 2025 03:00:56 +0000 (11:00 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 7 Jan 2026 15:06:33 +0000 (08:06 -0700)
commit641864314866dff382f64cd8b52fd6bf4c4d84f6
treedcaade36021f6054742699b89e462157e6639250
parentee623c892aa59003fca173de0041abc2ccc2c72d
block: don't initialize bi_vcnt for cloned bio in bio_iov_bvec_set()

bio_iov_bvec_set() creates a cloned bio that borrows a bvec array from
an iov_iter. For cloned bios, bi_vcnt is meaningless because iteration
is controlled entirely by bi_iter (bi_idx, bi_size, bi_bvec_done), not
by bi_vcnt. Remove the incorrect bi_vcnt assignment.

Explicitly initialize bi_iter.bi_idx to 0 to ensure iteration starts
at the first bvec. While bi_idx is typically already zero from bio
initialization, making this explicit improves clarity and correctness.

This change also avoids accessing iter->nr_segs, which is an iov_iter
implementation detail that block code should not depend on.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c