Commit fa4ae4be authored by Yury Kotov's avatar Yury Kotov Committed by Michael S. Tsirkin
Browse files

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: default avatarYury Kotov <yury-kotov@yandex-team.ru>
Acked-by: default avatarJia He <hejianet@gmail.com>
Cc: qemu-stable@nongnu.org
Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent c2d2a81b
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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;
    }