aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2020-12-16 11:03:41 -0500
committerThanos Makatos <tmakatos@gmail.com>2020-12-17 09:21:46 +0000
commitc0f982b1a373fd99235a31394fff12f935c1bde1 (patch)
treece5effc94f2e61fa1abe897917810f638f2a8e06 /lib
parent5273475d4798c5e4fe2d73775e96f2cd3acf3e97 (diff)
downloadlibvfio-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.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/dma.h b/lib/dma.h
index e0d6d72..aeed9bb 100644
--- a/lib/dma.h
+++ b/lib/dma.h
@@ -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++;