⬢ DragonFlyBSD Kernel Audit
DF-5546 / fix.diff
← back to finding ↓ download raw
--- sys/bus/u4b/controller/xhci_pci.c.orig
+++ sys/bus/u4b/controller/xhci_pci.c
@@ -366,16 +366,19 @@ xhci_pci_detach(device_t self)
 	if (sc->sc_irq_res) {
 		bus_release_resource(self, SYS_RES_IRQ,
 		    rman_get_rid(sc->sc_irq_res), sc->sc_irq_res);
 		sc->sc_irq_res = NULL;
 		pci_release_msi(self);
 	}
+	/*
+	 * pci_alloc_1intr() may have allocated MSI vectors even though no
+	 * IRQ resource was ever set up (forced polling mode,
+	 * hw.usb.xhci.use_polling=1). Release them here too; the call is
+	 * a harmless no-op (ENODEV) when nothing is allocated.
+	 */
+	pci_release_msi(self);
 	if (sc->sc_io_res) {
 		bus_release_resource(self, SYS_RES_MEMORY, PCI_XHCI_CBMEM,
 		    sc->sc_io_res);
 		sc->sc_io_res = NULL;
 	}