]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: iwlegacy: Check rate_idx range after addition
authorStanislaw Gruszka <stf_xl@wp.pl>
Sun, 25 May 2025 14:45:24 +0000 (16:45 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 20 Jun 2025 08:42:42 +0000 (10:42 +0200)
Limit rate_idx to IL_LAST_OFDM_RATE for 5GHz band for thinkable case
the index is incorrect.

Reported-by: Fedor Pchelkin <pchelkin@ispras.ru>
Reported-by: Alexei Safin <a.safin@rosa.ru>
Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
Reviewed-by: Fedor Pchelkin <pchelkin@ispras.ru>
Link: https://patch.msgid.link/20250525144524.GA172583@wp.pl
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlegacy/4965-mac.c

index 8e58e97a148f8ca0aae88f4b57041a3d3d5f5d6f..e9e007b48645cf7b35004cd652142f0a7fa0e620 100644 (file)
@@ -1575,8 +1575,11 @@ il4965_tx_cmd_build_rate(struct il_priv *il,
            || rate_idx > RATE_COUNT_LEGACY)
                rate_idx = rate_lowest_index(&il->bands[info->band], sta);
        /* For 5 GHZ band, remap mac80211 rate indices into driver indices */
-       if (info->band == NL80211_BAND_5GHZ)
+       if (info->band == NL80211_BAND_5GHZ) {
                rate_idx += IL_FIRST_OFDM_RATE;
+               if (rate_idx > IL_LAST_OFDM_RATE)
+                       rate_idx = IL_LAST_OFDM_RATE;
+       }
        /* Get PLCP rate for tx_cmd->rate_n_flags */
        rate_plcp = il_rates[rate_idx].plcp;
        /* Zero out flags for this packet */