diff options
author | William Henderson <william.henderson@nutanix.com> | 2023-08-02 11:42:42 +0000 |
---|---|---|
committer | John Levon <john.levon@nutanix.com> | 2023-09-15 12:59:39 +0100 |
commit | 970efd5d98f77baf130a9f1a2ef0880398c9146b (patch) | |
tree | cc083ed481e361ec140286a222cee9adf37eb2c3 | |
parent | 108932d519afd1b91d067f1ef0e237abdcc4e856 (diff) | |
download | libvfio-user-970efd5d98f77baf130a9f1a2ef0880398c9146b.zip libvfio-user-970efd5d98f77baf130a9f1a2ef0880398c9146b.tar.gz libvfio-user-970efd5d98f77baf130a9f1a2ef0880398c9146b.tar.bz2 |
fix: crash when not logging all DMA regions
Signed-off-by: William Henderson <william.henderson@nutanix.com>
-rw-r--r-- | lib/dma.c | 5 | ||||
-rw-r--r-- | lib/dma.h | 2 |
2 files changed, 6 insertions, 1 deletions
@@ -804,6 +804,11 @@ dma_controller_dirty_page_get(dma_controller_t *dma, vfu_dma_addr_t addr, return ERROR_INT(EINVAL); } + if (region->dirty_bitmap == NULL) { + vfu_log(dma->vfu_ctx, LOG_ERR, "region %d is not logged", sg.region); + return ERROR_INT(EINVAL); + } + for (i = 0; i < (size_t)bitmap_size; i++) { uint8_t val = region->dirty_bitmap[i]; uint8_t *outp = (uint8_t *)&bitmap[i]; @@ -373,7 +373,7 @@ dma_sgl_put(dma_controller_t *dma, dma_sg_t *sgl, size_t cnt) region = &dma->regions[sg->region]; if (sg->writeable) { - if (dma->dirty_pgsize > 0) { + if (dma->dirty_pgsize > 0 && region->dirty_bitmap != NULL) { _dma_mark_dirty(dma, region, sg); } } |