⬢ DragonFlyBSD Kernel Audit
DF-3664 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/netif/bge/if_bge.c
+++ b/sys/dev/netif/bge/if_bge.c
@@ -554,8 +554,12 @@
 			break;
 		DELAY(20);
 	}
-	if (i == 8000)
+	if (i == 8000) {
+		/* Drop the arbitration request before failing. */
+		CSR_WRITE_4(sc, BGE_NVRAM_SWARB, BGE_NVRAMSWARB_CLR1);
+		CSR_READ_4(sc, BGE_NVRAM_SWARB);
 		return (1);
+	}
 
 	/* Enable access. */
 	access = CSR_READ_4(sc, BGE_NVRAM_ACCESS);
@@ -573,6 +577,10 @@
 
 	if (i == BGE_TIMEOUT * 10) {
 		if_printf(&sc->arpcom.ac_if, "nvram read timed out\n");
+		/* Disable access and unlock before failing. */
+		CSR_WRITE_4(sc, BGE_NVRAM_ACCESS, access);
+		CSR_WRITE_4(sc, BGE_NVRAM_SWARB, BGE_NVRAMSWARB_CLR1);
+		CSR_READ_4(sc, BGE_NVRAM_SWARB);
 		return (1);
 	}