]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
vfio: Move PCI INTx eventfd setting earlier
authorAlex Williamson <alex.williamson@redhat.com>
Wed, 10 Oct 2012 15:10:32 +0000 (09:10 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Oct 2012 16:32:40 +0000 (09:32 -0700)
commit 9dbdfd23b7638d054f3b0e70c64dfb9f297f2a9f upstream.

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.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/vfio/pci/vfio_pci_intrs.c

index d8dedc7d3910c7bdc362dac6e099326642f0f1fb..c8139a598f846973c535026d91883edc94eabcc3 100644 (file)
@@ -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.