diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2021-11-01 12:08:47 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2021-11-01 12:08:47 +0000 |
commit | 3d1bbb51463cdc106ac2e392b9b49d40cb04dca4 (patch) | |
tree | eed7e0d69bfc1f143f2802d26d67b5bc0b204a25 | |
parent | 515a879e380267e8941d7a95ae1978657f8c00fd (diff) |
Restore some NULL checks lost in r1.132, add a couple more to deal with WEP key
installation happening w/o a node, and don't attempt to set WEP keys that don't
exist.
Should fix the '(null node)' panics reported by James Hastings.
ok stsp@
-rw-r--r-- | sys/dev/usb/if_run.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/dev/usb/if_run.c b/sys/dev/usb/if_run.c index 4da2468c393..f56262e7119 100644 --- a/sys/dev/usb/if_run.c +++ b/sys/dev/usb/if_run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_run.c,v 1.133 2021/10/31 12:17:54 stsp Exp $ */ +/* $OpenBSD: if_run.c,v 1.134 2021/11/01 12:08:46 krw Exp $ */ /*- * Copyright (c) 2008-2010 Damien Bergamini <damien.bergamini@free.fr> @@ -1968,7 +1968,7 @@ run_set_key_cb(struct run_softc *sc, void *arg) wcid = 0; /* NB: update WCID0 for group keys */ base = RT2860_SKEY(0, k->k_id); } else { - wcid = RUN_AID2WCID(cmd->ni->ni_associd); + wcid = (cmd->ni != NULL) ? RUN_AID2WCID(cmd->ni->ni_associd) : 0; base = RT2860_PKEY(wcid); } @@ -2021,7 +2021,8 @@ run_set_key_cb(struct run_softc *sc, void *arg) } if (sc->sc_key_tasks == 0) { - cmd->ni->ni_port_valid = 1; + if (cmd->ni != NULL) + cmd->ni->ni_port_valid = 1; ieee80211_set_link_state(ic, LINK_STATE_UP); } } @@ -2059,7 +2060,7 @@ run_delete_key_cb(struct run_softc *sc, void *arg) } else { /* remove pairwise key */ - wcid = RUN_AID2WCID(cmd->ni->ni_associd); + wcid = (cmd->ni != NULL) ? RUN_AID2WCID(cmd->ni->ni_associd) : 0; run_read(sc, RT2860_WCID_ATTR(wcid), &attr); attr &= ~0xf; run_write(sc, RT2860_WCID_ATTR(wcid), attr); @@ -4715,8 +4716,10 @@ run_init(struct ifnet *ifp) if (ic->ic_flags & IEEE80211_F_WEPON) { /* install WEP keys */ - for (i = 0; i < IEEE80211_WEP_NKID; i++) - (void)run_set_key(ic, NULL, &ic->ic_nw_keys[i]); + for (i = 0; i < IEEE80211_WEP_NKID; i++) { + if (ic->ic_nw_keys[i].k_cipher != IEEE80211_CIPHER_NONE) + (void)run_set_key(ic, NULL, &ic->ic_nw_keys[i]); + } } if (ic->ic_opmode == IEEE80211_M_MONITOR) |