mirror of
https://github.com/torvalds/linux
synced 2024-09-06 09:51:23 +00:00
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>
This commit is contained in:
parent
3a93e40326
commit
0a2481cde2
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue