Skip to contentSkip to conversation

iwlegacy: off by one in iwl3945_hw_build_tx_cmd_rate()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 20, 2011 – Nov 21, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iwlegacy: off by one in iwl3945_hw_build_tx_cmd_rate()

We use "rate_index" like this:

	rate = iwl3945_rates[rate_index].plcp;

The iwl3945_rates[] array has IWL_RATE_COUNT_3945 elements so the limit here is off by one.

drivers/net/wireless/iwlegacy/iwl-3945.c +1 -1
index f7c0a74..1627048 100644
@@ -676,7 +676,7 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv,
 				  int sta_id, int tx_id)
 {
 	u16 hw_value = ieee80211_get_tx_rate(priv->hw, info)->hw_value;
-	u16 rate_index = min(hw_value & 0xffff, IWL_RATE_COUNT_3945);
+	u16 rate_index = min(hw_value & 0xffff, IWL_RATE_COUNT_3945 - 1);
 	u16 rate_mask;
 	int rate;
 	u8 rts_retry_limit;
#1 lore raw
Quoted 6 lines · Dan Carpenter

We use "rate_index" like this:

	rate = iwl3945_rates[rate_index].plcp;

The iwl3945_rates[] array has IWL_RATE_COUNT_3945 elements so the limit here is off by one.

Thanks Dan. I queued patch into iwlegacy github tree on top of my current changes, otherwise there would be problems with merging.

Thanks
Stanislaw