From: Yury Kotov Date: Fri, 13 Jul 2018 14:04:05 +0000 (+0300) Subject: vhost: fix invalid downcast X-Git-Tag: v3.0.1~74 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bda754511881c2a8a8bbc64a111b24d488c749bc;p=thirdparty%2Fqemu.git vhost: fix invalid downcast virtio_queue_get_desc_addr returns 64-bit hwaddr while int is usually 32-bit. If returned hwaddr is not equal to 0 but least-significant 32 bits are equal to 0 then this code will not actually stop running queue. Signed-off-by: Yury Kotov Acked-by: Jia He Cc: qemu-stable@nongnu.org Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit fa4ae4be15fb08b37bec35139688ef563311d0b9) Signed-off-by: Michael Roth --- diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index d4cb5894a82..569c4053eae 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1073,10 +1073,8 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev, .index = vhost_vq_index, }; int r; - int a; - a = virtio_queue_get_desc_addr(vdev, idx); - if (a == 0) { + if (virtio_queue_get_desc_addr(vdev, idx) == 0) { /* Don't stop the virtqueue which might have not been started */ return; }