summaryrefslogtreecommitdiffstats
path: root/hw/display/virtio-gpu.c
diff options
context:
space:
mode:
authorLi Zhijian2020-08-27 05:58:55 +0200
committerGerd Hoffmann2020-09-04 10:12:56 +0200
commiteb398a54e33ab2ac9701839be9b660af3e50a32e (patch)
treea620afa598519e5e6210c7724ff6956f591795f4 /hw/display/virtio-gpu.c
parentMerge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-09-0... (diff)
downloadqemu-eb398a54e33ab2ac9701839be9b660af3e50a32e.tar.gz
qemu-eb398a54e33ab2ac9701839be9b660af3e50a32e.tar.xz
qemu-eb398a54e33ab2ac9701839be9b660af3e50a32e.zip
virtio-gpu: fix unmap the already mapped items
we go here either (!(*iov)[i].iov_base) or (len != l), so we need to consider to unmap the 'i'th item as well when the 'i'th item is not nil CC: Li Qiang <liq3ea@gmail.com> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> Message-id: 20200827035855.24354-1-lizhijian@cn.fujitsu.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/display/virtio-gpu.c')
-rw-r--r--hw/display/virtio-gpu.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 5f0dd7c150..90be4e3ed7 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -646,9 +646,9 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g,
uint64_t a = le64_to_cpu(ents[i].addr);
uint32_t l = le32_to_cpu(ents[i].length);
hwaddr len = l;
- (*iov)[i].iov_len = l;
(*iov)[i].iov_base = dma_memory_map(VIRTIO_DEVICE(g)->dma_as,
a, &len, DMA_DIRECTION_TO_DEVICE);
+ (*iov)[i].iov_len = len;
if (addr) {
(*addr)[i] = a;
}
@@ -656,6 +656,9 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g,
qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to map MMIO memory for"
" resource %d element %d\n",
__func__, ab->resource_id, i);
+ if ((*iov)[i].iov_base) {
+ i++; /* cleanup the 'i'th map */
+ }
virtio_gpu_cleanup_mapping_iov(g, *iov, i);
g_free(ents);
*iov = NULL;