Commit 86baf712 authored by Dan Carpenter's avatar Dan Carpenter Committed by John W. Linville

zd1211rw: fix potential array underflow

The first chunk fixes a debugging assert to print a warning about array underflows.
The second chunk corrects a potential array underflow.  I also removed an assert
in the second chunk because it can no longer happen.
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Acked-by: default avatarBenoit Papillault <benoit.papillault@free.fr>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 3082a2b7
...@@ -350,7 +350,7 @@ static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, ...@@ -350,7 +350,7 @@ static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
first_idx = info->status.rates[0].idx; first_idx = info->status.rates[0].idx;
ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates)); ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates));
retries = &zd_retry_rates[first_idx]; retries = &zd_retry_rates[first_idx];
ZD_ASSERT(0<=retry && retry<=retries->count); ZD_ASSERT(1 <= retry && retry <= retries->count);
info->status.rates[0].idx = retries->rate[0]; info->status.rates[0].idx = retries->rate[0];
info->status.rates[0].count = 1; // (retry > 1 ? 2 : 1); info->status.rates[0].count = 1; // (retry > 1 ? 2 : 1);
...@@ -360,7 +360,7 @@ static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, ...@@ -360,7 +360,7 @@ static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
info->status.rates[i].count = 1; // ((i==retry-1) && success ? 1:2); info->status.rates[i].count = 1; // ((i==retry-1) && success ? 1:2);
} }
for (; i<IEEE80211_TX_MAX_RATES && i<retry; i++) { for (; i<IEEE80211_TX_MAX_RATES && i<retry; i++) {
info->status.rates[i].idx = retries->rate[retry-1]; info->status.rates[i].idx = retries->rate[retry - 1];
info->status.rates[i].count = 1; // (success ? 1:2); info->status.rates[i].count = 1; // (success ? 1:2);
} }
if (i<IEEE80211_TX_MAX_RATES) if (i<IEEE80211_TX_MAX_RATES)
...@@ -424,12 +424,10 @@ void zd_mac_tx_failed(struct urb *urb) ...@@ -424,12 +424,10 @@ void zd_mac_tx_failed(struct urb *urb)
first_idx = info->status.rates[0].idx; first_idx = info->status.rates[0].idx;
ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates)); ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates));
retries = &zd_retry_rates[first_idx]; retries = &zd_retry_rates[first_idx];
if (retry < 0 || retry > retries->count) { if (retry <= 0 || retry > retries->count)
continue; continue;
}
ZD_ASSERT(0<=retry && retry<=retries->count); final_idx = retries->rate[retry - 1];
final_idx = retries->rate[retry-1];
final_rate = zd_rates[final_idx].hw_value; final_rate = zd_rates[final_idx].hw_value;
if (final_rate != tx_status->rate) { if (final_rate != tx_status->rate) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment