⬢ DragonFlyBSD Kernel Audit
DF-3594 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/netif/bwn/bwn/if_bwn.c
+++ b/sys/dev/netif/bwn/bwn/if_bwn.c
@@ -5186,6 +5186,12 @@ static void
 bwn_intr_noise(struct bwn_mac *mac)
 {
 	struct bwn_phy_g *pg = &mac->mac_phy.phy_g;
 	uint16_t tmp;
 	uint8_t noise[4];
 	uint8_t i, j;
 	int32_t average;
 
+	/*
+	 * The NOISESAMPLE_OK interrupt stays unmasked in mac_intr_mask;
+	 * a stale/duplicate interrupt after the 8-sample window closed
+	 * must not append a 9th sample (noi_samples is [8][4]).
+	 */
+	if (!mac->mac_noise.noi_running ||
+	    mac->mac_noise.noi_nsamples >= 8)
+		return;
+
 	if (mac->mac_phy.type != BWN_PHYTYPE_G)
 		return;
 
 	KASSERT(mac->mac_noise.noi_running, ("%s: fail", __func__));