Skip to content

Commit a8938bc

Browse files
Ariel Malamudjmberg-intel
authored andcommitted
wifi: iwlwifi: mvm: Add locking to the rate read flow
The rs_drv_get_rate flow reads the lq_sta to return the optimal rate for tx frames. This read flow is not protected thereby leaving a small window, a few instructions wide, open to contention by an asynchronous rate update. Indeed this race condition was hit and the update occurred in the middle of the read. Fix this by locking the lq_sta struct during read. Signed-off-by: Ariel Malamud <[email protected]> Signed-off-by: Gregory Greenman <[email protected]> Link: https://lore.kernel.org/r/20230514120631.b52c9ed5c379.I15290b78e0d966c1b68278263776ca9de841d5fe@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 207be64 commit a8938bc

File tree

1 file changed

+3
-0
lines changed
  • drivers/net/wireless/intel/iwlwifi/mvm

1 file changed

+3
-0
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/rs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,6 +2691,8 @@ static void rs_drv_get_rate(void *mvm_r, struct ieee80211_sta *sta,
26912691
return;
26922692

26932693
lq_sta = mvm_sta;
2694+
2695+
spin_lock(&lq_sta->pers.lock);
26942696
iwl_mvm_hwrate_to_tx_rate_v1(lq_sta->last_rate_n_flags,
26952697
info->band, &info->control.rates[0]);
26962698
info->control.rates[0].count = 1;
@@ -2705,6 +2707,7 @@ static void rs_drv_get_rate(void *mvm_r, struct ieee80211_sta *sta,
27052707
iwl_mvm_hwrate_to_tx_rate_v1(last_ucode_rate, info->band,
27062708
&txrc->reported_rate);
27072709
}
2710+
spin_unlock(&lq_sta->pers.lock);
27082711
}
27092712

27102713
static void *rs_drv_alloc_sta(void *mvm_rate, struct ieee80211_sta *sta,

0 commit comments

Comments
 (0)