virtio-gpu: fix unmap in error path
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 28 Jun 2019 07:23:57 +0000 (09:23 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 3 Jul 2019 06:57:09 +0000 (08:57 +0200)
We land here in case not everything we've asked for could be mapped.
So unmap only the bytes which have actually been mapped.

Also we didn't access anything, so acces_len can be 0.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Message-id: 20190628072357.31782-1-kraxel@redhat.com

hw/display/virtio-gpu.c

index 2b0f66b1d68d089503739a6529b1bf0a8ade2e2f..475a018c027c42b29515e43617d691fba2405f35 100644 (file)
@@ -1048,9 +1048,9 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
                 if (res->iov[i].iov_base) {
                     dma_memory_unmap(VIRTIO_DEVICE(g)->dma_as,
                                      res->iov[i].iov_base,
-                                     res->iov[i].iov_len,
+                                     len,
                                      DMA_DIRECTION_TO_DEVICE,
-                                     res->iov[i].iov_len);
+                                     0);
                 }
                 /* ...and the mappings for previous loop iterations */
                 res->iov_cnt = i;