From: Paolo Bonzini Date: Fri, 27 Jan 2017 15:40:19 +0000 (+0100) Subject: virtio: check for vring setup in virtio_queue_update_used_idx X-Git-Tag: v2.9.0-rc0~90^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ca0176ad8368668c5ad2b428361652e05984e930;p=thirdparty%2Fqemu.git virtio: check for vring setup in virtio_queue_update_used_idx If the vring has not been set up, it is not necessary for vring_used_idx to do anything (as is already the case when the caller is virtio_load). This is harmless for now, but it will be a problem when the MemoryRegionCache has not been set up. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index d62509d6cf7..cdafcec9be4 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2156,7 +2156,9 @@ void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx) void virtio_queue_update_used_idx(VirtIODevice *vdev, int n) { - vdev->vq[n].used_idx = vring_used_idx(&vdev->vq[n]); + if (vdev->vq[n].vring.desc) { + vdev->vq[n].used_idx = vring_used_idx(&vdev->vq[n]); + } } void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n)