The virtqueue's vdev points to the functional device, while the PCI I/O
register mapping belongs to its parent transport. The current lookup
therefore treats the functional driver's private data as transport data
and uses a queue pointer as the register base.
Queue deletion can overwrite the queue's list links and crash when
unlinking it. Fetch the parent transport's private data instead.
Fixes: 4135e10732a0 ("virtio: Add virtio over pci transport driver")
Signed-off-by: Bin Meng <[email protected]>
---
drivers/virtio/virtio_pci_legacy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/virtio/virtio_pci_legacy.c
b/drivers/virtio/virtio_pci_legacy.c
index 15f8c6e7d25..369c15bd88c 100644
--- a/drivers/virtio/virtio_pci_legacy.c
+++ b/drivers/virtio/virtio_pci_legacy.c
@@ -226,7 +226,7 @@ error_available:
static void virtio_pci_del_vq(struct virtqueue *vq)
{
- struct virtio_pci_priv *priv = dev_get_priv(vq->vdev);
+ struct virtio_pci_priv *priv = dev_get_priv(vq->vdev->parent);
unsigned int index = vq->index;
iowrite16(index, priv->ioaddr + VIRTIO_PCI_QUEUE_SEL);
--
2.53.0