⬢ DragonFlyBSD Kernel Audit
DF-3595 / 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
@@ -2039,6 +2039,13 @@ static void
 bwn_stop(struct bwn_softc *sc)
 {
 	struct bwn_mac *mac = sc->sc_curmac;
 
 	BWN_ASSERT_LOCKED(sc);
 
+	/*
+	 * sc_curmac is NULL after a failed band-switch / hwreset re-init
+	 * (bwn_switch_band fail:, bwn_hwreset out:).  Treat as down.
+	 */
+	if (mac == NULL) {
+		sc->sc_flags &= ~BWN_FLAG_RUNNING;
+		return;
+	}
+
 	DPRINTF(sc, BWN_DEBUG_RESET, "%s: called\n", __func__);
 
 	if (mac->mac_status >= BWN_MAC_STATUS_INITED) {