vfio/platform: Disable virqfds on cleanup
authorAlex Williamson <alex.williamson@redhat.com>
Fri, 8 Mar 2024 23:05:26 +0000 (16:05 -0700)
committerAlex Williamson <alex.williamson@redhat.com>
Mon, 11 Mar 2024 19:08:52 +0000 (13:08 -0600)
irqfds for mask and unmask that are not specifically disabled by the
user are leaked.  Remove any irqfds during cleanup

Cc: Eric Auger <eric.auger@redhat.com>
Cc: <stable@vger.kernel.org>
Fixes: a7fa7c77cf15 ("vfio/platform: implement IRQ masking/unmasking via an eventfd")
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Link: https://lore.kernel.org/r/20240308230557.805580-6-alex.williamson@redhat.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/platform/vfio_platform_irq.c

index 61a1bfb68ac7864b84c712c121e61190f230dcfa..e5dcada9e86c4521b88b7062cf4108ad456fcb68 100644 (file)
@@ -321,8 +321,11 @@ void vfio_platform_irq_cleanup(struct vfio_platform_device *vdev)
 {
        int i;
 
-       for (i = 0; i < vdev->num_irqs; i++)
+       for (i = 0; i < vdev->num_irqs; i++) {
+               vfio_virqfd_disable(&vdev->irqs[i].mask);
+               vfio_virqfd_disable(&vdev->irqs[i].unmask);
                vfio_set_trigger(vdev, i, -1, NULL);
+       }
 
        vdev->num_irqs = 0;
        kfree(vdev->irqs);