Skip to content

Commit

Permalink
mac80211: fix station rate table updates on assoc
Browse files Browse the repository at this point in the history
commit 18fe0fae61252b5ae6e26553e2676b5fac555951 upstream.

If the driver uses .sta_add, station entries are only uploaded after the sta
is in assoc state. Fix early station rate table updates by deferring them
until the sta has been uploaded.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Link: https://lore.kernel.org/r/20210201083324.3134-1-nbd@nbd.name
[use rcu_access_pointer() instead since we won't dereference here]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
nbd168 authored and blacksuan19 committed Feb 21, 2021
1 parent 0eb342a commit dc35c87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion net/mac80211/driver-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ int drv_sta_state(struct ieee80211_local *local,
} else if (old_state == IEEE80211_STA_AUTH &&
new_state == IEEE80211_STA_ASSOC) {
ret = drv_sta_add(local, sdata, &sta->sta);
if (ret == 0)
if (ret == 0) {
sta->uploaded = true;
if (rcu_access_pointer(sta->sta.rates))
drv_sta_rate_tbl_update(local, sdata, &sta->sta);
}
} else if (old_state == IEEE80211_STA_ASSOC &&
new_state == IEEE80211_STA_AUTH) {
drv_sta_remove(local, sdata, &sta->sta);
Expand Down
3 changes: 2 additions & 1 deletion net/mac80211/rate.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,8 @@ int rate_control_set_rates(struct ieee80211_hw *hw,
if (old)
kfree_rcu(old, rcu_head);

drv_sta_rate_tbl_update(hw_to_local(hw), sta->sdata, pubsta);
if (sta->uploaded)
drv_sta_rate_tbl_update(hw_to_local(hw), sta->sdata, pubsta);

ieee80211_sta_set_expected_throughput(pubsta, sta_get_expected_throughput(sta));

Expand Down

0 comments on commit dc35c87

Please sign in to comment.