Skip to content

Commit 852b1be

Browse files
author
Alex Williamson
committed
vfio/pci: Clear token on bypass registration failure
The eventfd context is used as our irqbypass token, therefore if an eventfd is re-used, our token is the same. The irqbypass code will return an -EBUSY in this case, but we'll still attempt to unregister the producer, where if that duplicate token still exists, results in removing the wrong object. Clear the token of failed producers so that they harmlessly fall out when unregistered. Fixes: 6d7425f ("vfio: Register/unregister irq_bypass_producer") Reported-by: guomin chen <guomin_chen@sina.com> Tested-by: guomin chen <guomin_chen@sina.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent 822e1a9 commit 852b1be

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎drivers/vfio/pci/vfio_pci_intrs.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,13 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
352352
vdev->ctx[vector].producer.token = trigger;
353353
vdev->ctx[vector].producer.irq = irq;
354354
ret = irq_bypass_register_producer(&vdev->ctx[vector].producer);
355-
if (unlikely(ret))
355+
if (unlikely(ret)) {
356356
dev_info(&pdev->dev,
357357
"irq bypass producer (token %p) registration fails: %d\n",
358358
vdev->ctx[vector].producer.token, ret);
359359

360+
vdev->ctx[vector].producer.token = NULL;
361+
}
360362
vdev->ctx[vector].trigger = trigger;
361363

362364
return 0;

0 commit comments

Comments
 (0)