diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -2190,7 +2190,7 @@ struct ieee80211_node_table *nt = &ic->ic_sta; struct ieee80211_node *nikey; ieee80211_keyix keyix; - int isowned, status; + int status; /* * NB: We must beware of LOR here; deleting the key @@ -2204,21 +2204,24 @@ * way to separate out this path so we must do this * conditionally. */ - isowned = IEEE80211_NODE_IS_LOCKED(nt); - if (!isowned) - IEEE80211_NODE_LOCK(nt); nikey = NULL; status = 1; /* NB: success */ + if (ni->ni_ucastkey.wk_keyix != IEEE80211_KEYIX_NONE) { keyix = ni->ni_ucastkey.wk_rxkeyix; status = ieee80211_crypto_delkey(ni->ni_vap, &ni->ni_ucastkey); - if (nt->nt_keyixmap != NULL && keyix < nt->nt_keyixmax) { - nikey = nt->nt_keyixmap[keyix]; - nt->nt_keyixmap[keyix] = NULL; + + if (!IEEE80211_NODE_IS_LOCKED(nt)) { + IEEE80211_NODE_LOCK(nt); + if (nt->nt_keyixmap != NULL && keyix < nt->nt_keyixmax) { + nikey = nt->nt_keyixmap[keyix]; + nt->nt_keyixmap[keyix] = NULL; + } + IEEE80211_NODE_UNLOCK(nt); + } else { + panic("%s:%d: node locked?", __func__, __LINE__); } } - if (!isowned) - IEEE80211_NODE_UNLOCK(nt); if (nikey != NULL) { KASSERT(nikey == ni,