ath9k: fix sta initialization bug leading to stability issues
[librecmc/librecmc.git] / package / kernel / mac80211 / patches / 320-ath9k-fix-using-sta-drv_priv-before-initializing-it.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Tue, 2 Aug 2016 13:00:01 +0200
3 Subject: [PATCH] ath9k: fix using sta->drv_priv before initializing it
4
5 A station pointer can be passed to the driver on tx, before it has been
6 marked as associated. Since ath9k_sta_state was initializing the entry
7 too late, it resulted in some spurious crashes.
8
9 Fixes: df3c6eb34da5 ("ath9k: Use sta_state() callback")
10 Cc: stable@vger.kernel.org
11 Signed-off-by: Felix Fietkau <nbd@nbd.name>
12 ---
13
14 --- a/drivers/net/wireless/ath/ath9k/main.c
15 +++ b/drivers/net/wireless/ath/ath9k/main.c
16 @@ -1563,13 +1563,13 @@ static int ath9k_sta_state(struct ieee80
17         struct ath_common *common = ath9k_hw_common(sc->sc_ah);
18         int ret = 0;
19  
20 -       if (old_state == IEEE80211_STA_AUTH &&
21 -           new_state == IEEE80211_STA_ASSOC) {
22 +       if (old_state == IEEE80211_STA_NOTEXIST &&
23 +           new_state == IEEE80211_STA_NONE) {
24                 ret = ath9k_sta_add(hw, vif, sta);
25                 ath_dbg(common, CONFIG,
26                         "Add station: %pM\n", sta->addr);
27 -       } else if (old_state == IEEE80211_STA_ASSOC &&
28 -                  new_state == IEEE80211_STA_AUTH) {
29 +       } else if (old_state == IEEE80211_STA_NONE &&
30 +                  new_state == IEEE80211_STA_NOTEXIST) {
31                 ret = ath9k_sta_remove(hw, vif, sta);
32                 ath_dbg(common, CONFIG,
33                         "Remove station: %pM\n", sta->addr);