Skip to content

Commit

Permalink
vfio: Move PCI INTx eventfd setting earlier
Browse files Browse the repository at this point in the history
We need to be ready to recieve an interrupt as soon as we call
request_irq, so our eventfd context setting needs to be moved
earlier.  Without this, an interrupt from our device or one
sharing the interrupt line can pass a NULL into eventfd_signal
and oops.

Cc: stable@vger.kernel.org
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
Alex Williamson committed Oct 10, 2012
1 parent 34002f5 commit 9dbdfd2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/vfio/pci/vfio_pci_intrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,19 +400,20 @@ static int vfio_intx_set_signal(struct vfio_pci_device *vdev, int fd)
return PTR_ERR(trigger);
}

vdev->ctx[0].trigger = trigger;

if (!vdev->pci_2_3)
irqflags = 0;

ret = request_irq(pdev->irq, vfio_intx_handler,
irqflags, vdev->ctx[0].name, vdev);
if (ret) {
vdev->ctx[0].trigger = NULL;
kfree(vdev->ctx[0].name);
eventfd_ctx_put(trigger);
return ret;
}

vdev->ctx[0].trigger = trigger;

/*
* INTx disable will stick across the new irq setup,
* disable_irq won't.
Expand Down

0 comments on commit 9dbdfd2

Please sign in to comment.