wifi: mac80211: mlme: fix null-ptr deref on failed assoc
authorJohannes Berg <johannes.berg@intel.com>
Wed, 21 Sep 2022 00:44:58 +0000 (02:44 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:01 +0000 (13:32 +0100)
commitbb7743955a929e44b308cc3f63f8cc03873c1bee
tree7d83c7ec075e550f3e125a067db78e236fe9b1a2
parentcd5d16539330a1d237bd8f44fedac123ee630644
wifi: mac80211: mlme: fix null-ptr deref on failed assoc

[ Upstream commit 78a6a43aaf87180ec7425a2a90468e1b4d09a1ec ]

If association to an AP without a link 0 fails, then we crash in
tracing because it assumes that either ap_mld_addr or link 0 BSS
is valid, since we clear sdata->vif.valid_links and then don't
add the ap_mld_addr to the struct.

Since we clear also sdata->vif.cfg.ap_addr, keep a local copy of
it and assign it earlier, before clearing valid_links, to fix
this.

Fixes: 81151ce462e5 ("wifi: mac80211: support MLO authentication/association with one link")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/mac80211/mlme.c