Skip to content

Commit

Permalink
block: ensure bio_alloc_map_data() deals with ITER_UBUF correctly
Browse files Browse the repository at this point in the history
This helper blindly copies the iovec, even if we don't have one.
Make this case a bit smarter by only doing so if we have an iovec
array to copy.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
axboe committed Mar 29, 2023
1 parent 3a93e40 commit 0a2481c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions block/blk-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ static struct bio_map_data *bio_alloc_map_data(struct iov_iter *data,
bmd = kmalloc(struct_size(bmd, iov, data->nr_segs), gfp_mask);
if (!bmd)
return NULL;
memcpy(bmd->iov, data->iov, sizeof(struct iovec) * data->nr_segs);
bmd->iter = *data;
if (iter_is_iovec(data))
if (iter_is_iovec(data)) {
memcpy(bmd->iov, data->iov, sizeof(struct iovec) * data->nr_segs);
bmd->iter.iov = bmd->iov;
}
return bmd;
}

Expand Down

0 comments on commit 0a2481c

Please sign in to comment.