wifi: mac80211: avoid weird state in error path
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Mon, 9 Jun 2025 18:35:13 +0000 (21:35 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 9 Jul 2025 09:41:38 +0000 (11:41 +0200)
commitbe1ba9ed221ffb95a8bb15f4c83d0694225ba808
tree9e4b8e0e05d4ff63fe229dec66ae0ba1b1a740a6
parentc8c5e97da9fe77177181930838acb3090a08b7bb
wifi: mac80211: avoid weird state in error path

If we get to the error path of ieee80211_prep_connection, for example
because of a FW issue, then ieee80211_vif_set_links is called
with 0.
But the call to drv_change_vif_links from ieee80211_vif_update_links
will probably fail as well, for the same reason.
In this case, the valid_links and active_links bitmaps will be reverted
to the value of the failing connection.
Then, in the next connection, due to the logic of
ieee80211_set_vif_links_bitmaps, valid_links will be set to the ID of
the new connection assoc link, but the active_links will remain with the
ID of the old connection's assoc link.
If those IDs are different, we get into a weird state of valid_links and
active_links being different. One of the consequences of this state is
to call drv_change_vif_links with new_links as 0, since the & operation
between the bitmaps will be 0.

Since a removal of a link should always succeed, ignore the return value
of drv_change_vif_links if it was called to only remove links, which is
the case for the ieee80211_prep_connection's error path.
That way, the bitmaps will not be reverted to have the value from the
failing connection and will have 0, so the next connection will have a
good state.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Link: https://patch.msgid.link/20250609213231.ba2011fb435f.Id87ff6dab5e1cf757b54094ac2d714c656165059@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/mac80211.h
net/mac80211/link.c