[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 04/41] virtio: convert to use DMA api
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PULL 04/41] virtio: convert to use DMA api |
Date: |
Wed, 18 Jan 2017 12:59:03 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 |
On 10/01/2017 06:39, Michael S. Tsirkin wrote:
> -void virtqueue_map(VirtQueueElement *elem)
> +void virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem)
> {
> - virtqueue_map_iovec(elem->in_sg, elem->in_addr, &elem->in_num,
> - VIRTQUEUE_MAX_SIZE, 1);
> - virtqueue_map_iovec(elem->out_sg, elem->out_addr, &elem->out_num,
> - VIRTQUEUE_MAX_SIZE, 0);
> + virtqueue_map_iovec(vdev, elem->in_sg, elem->in_addr, &elem->in_num,
> + MIN(ARRAY_SIZE(elem->in_sg),
> ARRAY_SIZE(elem->in_addr)),
> + 1);
> + virtqueue_map_iovec(vdev, elem->out_sg, elem->out_addr, &elem->out_num,
> + MIN(ARRAY_SIZE(elem->out_sg),
> + ARRAY_SIZE(elem->out_addr)),
> + 0);
Coverity reports that ARRAY_SIZE(elem->out_sg) (and all the others too)
is wrong because elem->out_sg is a pointer.
However, the check is not in the right place and the max_size argument
of virtqueue_map_iovec can be removed. The check on in_num/out_num can
be moved to qemu_get_virtqueue_element instead, before the call to
virtqueue_alloc_element.
Thanks,
Paolo
- [Qemu-devel] [PULL 00/41] virtio, vhost, pc: fixes, features, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 01/41] migration: allow to prioritize save state entries, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 02/41] intel_iommu: allow migration, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 03/41] virtio-crypto: fix possible integer and heap overflow, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 05/41] intel_iommu: name vtd address space with devfn, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 06/41] intel_iommu: allocate new key when creating new address space, Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 04/41] virtio: convert to use DMA api, Michael S. Tsirkin, 2017/01/10
- Re: [Qemu-devel] [PULL 04/41] virtio: convert to use DMA api,
Paolo Bonzini <=
- [Qemu-devel] [PULL 07/41] exec: introduce address_space_get_iotlb_entry(), Michael S. Tsirkin, 2017/01/10
- [Qemu-devel] [PULL 08/41] intel_iommu: support device iotlb descriptor, Michael S. Tsirkin, 2017/01/10