⬢ DragonFlyBSD Kernel Audit
DF-5261 / fix.diff
← back to finding ↓ download raw
--- a/sys/bus/u4b/wlan/if_mtw.c
+++ b/sys/bus/u4b/wlan/if_mtw.c
@@ -2168,11 +2168,14 @@
 	uint8_t wcid, mcs, pid;
 	int8_t retry;
 
+	int ntries;
+
 	MTW_LOCK_ASSERT(sc);
 
-	for (;;) {
+	for (ntries = 0; ntries < 64; ntries++) {	/* FIFO depth is 16 */
 		/* drain Tx status FIFO (maxsize = 16) */
-		mtw_read(sc, MTW_TX_STAT_FIFO, &stat);
+		if (mtw_read(sc, MTW_TX_STAT_FIFO, &stat) != 0)
+			break;
 		MTW_DPRINTF(sc, MTW_DEBUG_XMIT, "tx stat 0x%08x\n", stat);
 		if (!(stat & MTW_TXQ_VLD))
 			break;