Skip to contentSkip to conversation

wifi: mac80211: unwind via out_err when ieee80211_vif_set_links() fails

PATCH New Chengyu Liu 1 participant 1 message Nov 4 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: mac80211: unwind via out_err when ieee80211_vif_set_links() fails

In ieee80211_prep_connection() with assoc set, the station obtained by sta_info_get() is owned by this flow for MLO and must not survive a failed connection prep: on failure the interface is reset to non-MLD, and a station tied to the torn-down link triggers the use-after-free/double-free on debugfs recreation fixed by commit 283fc9e44ff5 ("wifi: mac80211: remove station if connection prep fails").

That commit put the station destroy in out_err, but the ieee80211_vif_set_links() error path returns before out_err, so a set_links failure still leaves the station behind and keeps that bug reachable.

Route the failure through out_err like the later error paths do; its extra ieee80211_vif_set_links(sdata, 0, 0) is the function's established unwind.

Found by static analysis.

Fixes 283fc9e44ff5 ("wifi: mac80211: remove station if connection prep fails")
---
 net/mac80211/mlme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/mlme.c +1 -1
index 3c31c16860..24fbdaabff 100644
@@ -9633,7 +9633,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
 
 	err = ieee80211_vif_set_links(sdata, new_links, 0);
 	if (err)
-		return err;
+		goto out_err;
 
 	link = sdata_dereference(sdata->link[link_id], sdata);
 	if (WARN_ON(!link)) {
Signature · 1 line
2.25.1