Skip to content

Commit d567fb8

Browse files
Jiang Yiawilliam
authored andcommitted
vfio/pci: call irq_bypass_unregister_producer() before freeing irq
Since irq_bypass_register_producer() is called after request_irq(), we should do tear-down in reverse order: irq_bypass_unregister_producer() then free_irq(). Specifically free_irq() may release resources required by the irqbypass del_producer() callback. Notably an example provided by Marc Zyngier on arm64 with GICv4 that he indicates has the potential to wedge the hardware: free_irq(irq) __free_irq(irq) irq_domain_deactivate_irq(irq) its_irq_domain_deactivate() [unmap the VLPI from the ITS] kvm_arch_irq_bypass_del_producer(cons, prod) kvm_vgic_v4_unset_forwarding(kvm, irq, ...) its_unmap_vlpi(irq) [Unmap the VLPI from the ITS (again), remap the original LPI] Signed-off-by: Jiang Yi <[email protected]> Cc: [email protected] # v4.4+ Fixes: 6d7425f ("vfio: Register/unregister irq_bypass_producer") Link: https://lore.kernel.org/kvm/[email protected] Reviewed-by: Marc Zyngier <[email protected]> Reviewed-by: Eric Auger <[email protected]> [aw: commit log] Signed-off-by: Alex Williamson <[email protected]>
1 parent 4f5cafb commit d567fb8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/vfio/pci/vfio_pci_intrs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
294294
irq = pci_irq_vector(pdev, vector);
295295

296296
if (vdev->ctx[vector].trigger) {
297-
free_irq(irq, vdev->ctx[vector].trigger);
298297
irq_bypass_unregister_producer(&vdev->ctx[vector].producer);
298+
free_irq(irq, vdev->ctx[vector].trigger);
299299
kfree(vdev->ctx[vector].name);
300300
eventfd_ctx_put(vdev->ctx[vector].trigger);
301301
vdev->ctx[vector].trigger = NULL;

0 commit comments

Comments
 (0)