summaryrefslogtreecommitdiff
path: root/block/blk-map.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2023-03-28 15:10:31 -0600
committerJens Axboe <axboe@kernel.dk>2023-03-29 08:55:18 -0600
commit0a2481cde24f78f503cbc066df2c9c160e64cfd6 (patch)
tree2d9ab0a38d3580220639c5677ae7f690dc6afe3b /block/blk-map.c
parent3a93e40326c8f470e71d20b4c42d36767450f38f (diff)
block: ensure bio_alloc_map_data() deals with ITER_UBUF correctly
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>
Diffstat (limited to 'block/blk-map.c')
-rw-r--r--block/blk-map.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/block/blk-map.c b/block/blk-map.c
index 9137d16cecdc..3bfcad64d67c 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -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;
}