提交 6a028d9a 编写于 作者: E Eyal Shapira 提交者: Emmanuel Grumbach

iwlwifi: mvm: rs: fix max rate allowed if no rate is allowed

In case the rate mask for one of the modulations was zero the
max rate idx for that modulation was set to 32 (BITS_PER_LONG).
This is bad as it would later lead to an out of bounds access
to the expected tpt table. In most cases there was no real effect
as the expected tpt was set to 0 and this led to avoiding the
modulation effectively.
Fix the out of bounds access and explicitly skip the modulation
in case there's no rate allowed in it.
Signed-off-by: NEyal Shapira <eyalx.shapira@intel.com>
Signed-off-by: NEmmanuel Grumbach <emmanuel.grumbach@intel.com>
上级 19789abb
...@@ -1318,6 +1318,13 @@ static void rs_set_stay_in_table(struct iwl_mvm *mvm, u8 is_legacy, ...@@ -1318,6 +1318,13 @@ static void rs_set_stay_in_table(struct iwl_mvm *mvm, u8 is_legacy,
lq_sta->visited_columns = 0; lq_sta->visited_columns = 0;
} }
static inline int rs_get_max_rate_from_mask(unsigned long rate_mask)
{
if (rate_mask)
return find_last_bit(&rate_mask, BITS_PER_LONG);
return IWL_RATE_INVALID;
}
static int rs_get_max_allowed_rate(struct iwl_lq_sta *lq_sta, static int rs_get_max_allowed_rate(struct iwl_lq_sta *lq_sta,
const struct rs_tx_column *column) const struct rs_tx_column *column)
{ {
...@@ -1613,8 +1620,12 @@ static enum rs_column rs_get_next_column(struct iwl_mvm *mvm, ...@@ -1613,8 +1620,12 @@ static enum rs_column rs_get_next_column(struct iwl_mvm *mvm,
continue; continue;
max_rate = rs_get_max_allowed_rate(lq_sta, next_col); max_rate = rs_get_max_allowed_rate(lq_sta, next_col);
if (WARN_ON_ONCE(max_rate == IWL_RATE_INVALID)) if (max_rate == IWL_RATE_INVALID) {
IWL_DEBUG_RATE(mvm,
"Skip column %d: no rate is allowed in this column\n",
next_col_id);
continue; continue;
}
max_expected_tpt = expected_tpt_tbl[max_rate]; max_expected_tpt = expected_tpt_tbl[max_rate];
if (tpt >= max_expected_tpt) { if (tpt >= max_expected_tpt) {
...@@ -2765,12 +2776,12 @@ void iwl_mvm_rs_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta, ...@@ -2765,12 +2776,12 @@ void iwl_mvm_rs_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
if (IWL_MVM_RS_DISABLE_MIMO) if (IWL_MVM_RS_DISABLE_MIMO)
lq_sta->active_mimo2_rate = 0; lq_sta->active_mimo2_rate = 0;
lq_sta->max_legacy_rate_idx = find_last_bit(&lq_sta->active_legacy_rate, lq_sta->max_legacy_rate_idx =
BITS_PER_LONG); rs_get_max_rate_from_mask(lq_sta->active_legacy_rate);
lq_sta->max_siso_rate_idx = find_last_bit(&lq_sta->active_siso_rate, lq_sta->max_siso_rate_idx =
BITS_PER_LONG); rs_get_max_rate_from_mask(lq_sta->active_siso_rate);
lq_sta->max_mimo2_rate_idx = find_last_bit(&lq_sta->active_mimo2_rate, lq_sta->max_mimo2_rate_idx =
BITS_PER_LONG); rs_get_max_rate_from_mask(lq_sta->active_mimo2_rate);
IWL_DEBUG_RATE(mvm, IWL_DEBUG_RATE(mvm,
"RATE MASK: LEGACY=%lX SISO=%lX MIMO2=%lX VHT=%d LDPC=%d STBC%d\n", "RATE MASK: LEGACY=%lX SISO=%lX MIMO2=%lX VHT=%d LDPC=%d STBC%d\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册