Skip to content

Commit

Permalink
rs: add a few rate index validity checks. Validate index before acces…
Browse files Browse the repository at this point in the history
…s iwl_rate_mcs to keep rate->index inside the valid boundaries. Use MCS_0_INDEX if index is less than MCS_0_INDEX and MCS_9_INDEX if index is greater then MCS_9_INDEX.
  • Loading branch information
zxystd committed Feb 24, 2024
1 parent 409ba22 commit 3999899
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions itlwm/hal_iwm/rs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,10 @@ static char *rs_pretty_rate(const struct rs_rate *rate)
(rate->index <= IWL_RATE_MCS_9_INDEX))
rate_str = ht_vht_rates[rate->index];
else
rate_str = "BAD_RATE";
rate_str = NULL;

snprintf(buf, sizeof(buf), "(%s|%s|%s)", rs_pretty_lq_type(rate->type),
rs_pretty_ant(rate->ant), rate_str);
rs_pretty_ant(rate->ant), rate_str ?: "BAD_RATE");
return buf;
}

Expand Down Expand Up @@ -1096,10 +1096,13 @@ static void rs_get_lower_rate_down_column(struct iwl_lq_sta *lq_sta,

rate->bw = RATE_MCS_CHAN_WIDTH_20;

WARN_ON_ONCE(rate->index < IWL_RATE_MCS_0_INDEX ||
rate->index > IWL_RATE_MCS_9_INDEX);
if (WARN_ON_ONCE(rate->index < IWL_RATE_MCS_0_INDEX))
rate->index = rs_ht_to_legacy[IWL_RATE_MCS_0_INDEX];
else if (WARN_ON_ONCE(rate->index > IWL_RATE_MCS_9_INDEX))
rate->index = rs_ht_to_legacy[IWL_RATE_MCS_9_INDEX];
else
rate->index = rs_ht_to_legacy[rate->index];

rate->index = rs_ht_to_legacy[rate->index];
rate->ldpc = false;
} else {
/* Downgrade to SISO with same MCS if in MIMO */
Expand Down

0 comments on commit 3999899

Please sign in to comment.