diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2020-12-16 11:03:41 -0500 |
---|---|---|
committer | Thanos Makatos <tmakatos@gmail.com> | 2020-12-17 09:21:46 +0000 |
commit | c0f982b1a373fd99235a31394fff12f935c1bde1 (patch) | |
tree | ce5effc94f2e61fa1abe897917810f638f2a8e06 /lib | |
parent | 5273475d4798c5e4fe2d73775e96f2cd3acf3e97 (diff) | |
download | libvfio-user-c0f982b1a373fd99235a31394fff12f935c1bde1.zip libvfio-user-c0f982b1a373fd99235a31394fff12f935c1bde1.tar.gz libvfio-user-c0f982b1a373fd99235a31394fff12f935c1bde1.tar.bz2 |
fail to map segment if DMA region isn't backed by file descriptor
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dma.h | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -246,9 +246,12 @@ dma_map_sg(dma_controller_t *dma, const dma_sg_t *sg, struct iovec *iov, if (sg[i].region >= dma->nregions) { return -EINVAL; } + region = &dma->regions[sg[i].region]; + if (region->virt_addr == NULL) { + return -EFAULT; + } vfu_log(dma->vfu_ctx, LOG_DEBUG, "map %#lx-%#lx\n", sg->dma_addr + sg->offset, sg->dma_addr + sg->offset + sg->length); - region = &dma->regions[sg[i].region]; iov[i].iov_base = region->virt_addr + sg[i].offset; iov[i].iov_len = sg[i].length; region->refcnt++; |