Skip to content

Commit d599f71

Browse files
jmberg-intelKalle Valo
authored andcommitted
iwlwifi: mvm: don't crash on invalid rate w/o STA
If we get to the WARN_ONCE(..., "Got a HT rate (...)", ...) here with a NULL sta, then we crash because mvmsta is bad and we try to dereference it. Fix that by printing -1 as the state if no station was given. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Fixes: 6761a71 ("iwlwifi: mvm: add explicit check for non-data frames in get Tx rate") Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/iwlwifi.20211203140410.1a1541d7dcb5.I606c746e11447fe168cf046376b70b04e278c3b4@changeid
1 parent 06d59d6 commit d599f71

File tree

1 file changed

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

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,18 @@ static u32 iwl_mvm_get_tx_rate(struct iwl_mvm *mvm,
269269
u8 rate_plcp;
270270
u32 rate_flags = 0;
271271
bool is_cck;
272-
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
273272

274273
/* info->control is only relevant for non HW rate control */
275274
if (!ieee80211_hw_check(mvm->hw, HAS_RATE_CONTROL)) {
275+
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
276+
276277
/* HT rate doesn't make sense for a non data frame */
277278
WARN_ONCE(info->control.rates[0].flags & IEEE80211_TX_RC_MCS &&
278279
!ieee80211_is_data(fc),
279280
"Got a HT rate (flags:0x%x/mcs:%d/fc:0x%x/state:%d) for a non data frame\n",
280281
info->control.rates[0].flags,
281282
info->control.rates[0].idx,
282-
le16_to_cpu(fc), mvmsta->sta_state);
283+
le16_to_cpu(fc), sta ? mvmsta->sta_state : -1);
283284

284285
rate_idx = info->control.rates[0].idx;
285286
}

0 commit comments

Comments
 (0)