mac80211: fix station rate table updates on assoc
authorFelix Fietkau <nbd@nbd.name>
Mon, 1 Feb 2021 08:33:24 +0000 (09:33 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 1 Feb 2021 14:07:09 +0000 (15:07 +0100)
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>
net/mac80211/driver-ops.c
net/mac80211/rate.c

index c9a8a2433e8ac51f9c63827887113b357ea23a95..48322e45e7ddb56f82a6c762fed757368cbdeb91 100644 (file)
@@ -125,8 +125,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);
index 45927202c71c6e0664331e2347cb40c9ed1170c3..63652c39c8e07df537901b3f19a4e6d979d4c5a3 100644 (file)
@@ -960,7 +960,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));