DragonFlyBSD Kernel Audit
DF-2031 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/raid/mfi/mfi_pci.c b/sys/dev/raid/mfi/mfi_pci.c
--- a/sys/dev/raid/mfi/mfi_pci.c
+++ b/sys/dev/raid/mfi/mfi_pci.c
@@ -287,8 +287,11 @@
 	    &sc->mfi_irq_rid, &irq_flags);
 	if ((sc->mfi_irq = bus_alloc_resource_any(sc->mfi_dev, SYS_RES_IRQ,
 	    &sc->mfi_irq_rid, irq_flags)) == NULL) {
+		/* DF-2031: clean up already-allocated BAR/DMA-tag/MSI via the
+		 * out: label instead of returning directly and leaking them. */
 		device_printf(sc->mfi_dev, "Cannot allocate interrupt\n");
-		return (EINVAL);
+		error = EINVAL;
+		goto out;
 	}
 
 	error = mfi_attach(sc);