Skip to content

Commit 2965c4c

Browse files
jmberg-intelKalle Valo
authored and
Kalle Valo
committed
wifi: mac80211: fix use-after-free in chanctx code
In ieee80211_vif_use_reserved_context(), when we have an old context and the new context's replace_state is set to IEEE80211_CHANCTX_REPLACE_NONE, we free the old context in ieee80211_vif_use_reserved_reassign(). Therefore, we cannot check the old_ctx anymore, so we should set it to NULL after this point. However, since the new_ctx replace state is clearly not IEEE80211_CHANCTX_REPLACES_OTHER, we're not going to do anything else in this function and can just return to avoid accessing the freed old_ctx. Cc: [email protected] Fixes: 5bcae31 ("mac80211: implement multi-vif in-place reservations") Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/20220601091926.df419d91b165.I17a9b3894ff0b8323ce2afdb153b101124c821e5@changeid
1 parent 7711fe7 commit 2965c4c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

net/mac80211/chan.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -1749,12 +1749,9 @@ int ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata)
17491749

17501750
if (new_ctx->replace_state == IEEE80211_CHANCTX_REPLACE_NONE) {
17511751
if (old_ctx)
1752-
err = ieee80211_vif_use_reserved_reassign(sdata);
1753-
else
1754-
err = ieee80211_vif_use_reserved_assign(sdata);
1752+
return ieee80211_vif_use_reserved_reassign(sdata);
17551753

1756-
if (err)
1757-
return err;
1754+
return ieee80211_vif_use_reserved_assign(sdata);
17581755
}
17591756

17601757
/*

0 commit comments

Comments
 (0)