aboutsummaryrefslogtreecommitdiff
path: root/lib/dma.c
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2020-02-27 09:19:50 -0500
committerThanos Makatos <thanos.makatos@nutanix.com>2020-02-28 06:30:23 -0500
commit05e0ab1b38cee3dacbfff7b4cc06e4b74290f2f4 (patch)
treec29b2c7635f13696661546f027758a9dbd1888ce /lib/dma.c
parent4a35a27cecb4d61e891967c751bda799a7492a9b (diff)
downloadlibvfio-user-05e0ab1b38cee3dacbfff7b4cc06e4b74290f2f4.zip
libvfio-user-05e0ab1b38cee3dacbfff7b4cc06e4b74290f2f4.tar.gz
libvfio-user-05e0ab1b38cee3dacbfff7b4cc06e4b74290f2f4.tar.bz2
don't dup DMA region fd
fixes #47 Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib/dma.c')
-rw-r--r--lib/dma.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/dma.c b/lib/dma.c
index 17e34e8..1a86f6f 100644
--- a/lib/dma.c
+++ b/lib/dma.c
@@ -207,13 +207,7 @@ dma_controller_add_region(lm_ctx_t *lm_ctx, dma_controller_t *dma,
region->size = size;
region->page_size = page_size;
region->offset = offset;
-
- region->fd = dup(fd); // dup the fd to get our own private copy
- if (region->fd < 0) {
- lm_log(lm_ctx, LM_ERR, "failed to duplicate file descriptor: %s\n",
- strerror(errno));
- goto err;
- }
+ region->fd = fd;
region->virt_addr = dma_map_region(region, PROT_READ | PROT_WRITE,
0, region->size);