@@ -224,10 +224,12 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
virtqueue_get_avail_addr(vq),
virtqueue_get_used_addr(vq));
- vq->priv = (void __force *)vp_modern_map_vq_notify(mdev, index, NULL);
if (!vq->priv) {
- err = -ENOMEM;
- goto err_map_notify;
+ vq->priv = (void __force *)vp_modern_map_vq_notify(mdev, index, NULL);
+ if (!vq->priv) {
+ err = -ENOMEM;
+ goto err_map_notify;
+ }
}
if (msix_vec != VIRTIO_MSI_NO_VECTOR) {
@@ -1723,6 +1723,7 @@ static struct virtqueue *vring_create_virtqueue_packed(
vq->vq.callback = callback;
vq->vq.name = name;
+ vq->vq.priv = NULL;
vq->indirect = virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC) &&
!context;
}
@@ -2211,6 +2212,7 @@ static int __vring_init_virtqueue(struct virtqueue *_vq,
if (!reset) {
vq->vq.callback = callback;
vq->vq.name = name;
+ vq->vq.priv = NULL;
vq->indirect = virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC) &&
!context;
}
Reserve vq->priv during reset. Prevent vp_modern_map_vq_notify() from being called repeatedly. Only set vq->priv = NULL in normal setup virtqueue, and keep vq->priv in the process of re-enable queue. Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> --- drivers/virtio/virtio_pci_modern.c | 8 +++++--- drivers/virtio/virtio_ring.c | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-)