aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/zd1211rw/zd_mac.c
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2010-02-27 01:12:34 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-03-02 14:28:49 -0500
commit86baf712295a00d664da8566186b67041c89b15b (patch)
tree1c9fca9c5633e552aaf3f2b9acc26f5e21d12592 /drivers/net/wireless/zd1211rw/zd_mac.c
parent3082a2b7b1af1b1508c1c3fa589566064f926f40 (diff)
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: Dan Carpenter <error27@gmail.com> Acked-by: Benoit Papillault <benoit.papillault@free.fr> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/zd1211rw/zd_mac.c')
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 2d555cc30508..e24099613d91 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -350,7 +350,7 @@ static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
350 first_idx = info->status.rates[0].idx; 350 first_idx = info->status.rates[0].idx;
351 ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates)); 351 ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates));
352 retries = &zd_retry_rates[first_idx]; 352 retries = &zd_retry_rates[first_idx];
353 ZD_ASSERT(0<=retry && retry<=retries->count); 353 ZD_ASSERT(1 <= retry && retry <= retries->count);
354 354
355 info->status.rates[0].idx = retries->rate[0]; 355 info->status.rates[0].idx = retries->rate[0];
356 info->status.rates[0].count = 1; // (retry > 1 ? 2 : 1); 356 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 info->status.rates[i].count = 1; // ((i==retry-1) && success ? 1:2); 360 info->status.rates[i].count = 1; // ((i==retry-1) && success ? 1:2);
361 } 361 }
362 for (; i<IEEE80211_TX_MAX_RATES && i<retry; i++) { 362 for (; i<IEEE80211_TX_MAX_RATES && i<retry; i++) {
363 info->status.rates[i].idx = retries->rate[retry-1]; 363 info->status.rates[i].idx = retries->rate[retry - 1];
364 info->status.rates[i].count = 1; // (success ? 1:2); 364 info->status.rates[i].count = 1; // (success ? 1:2);
365 } 365 }
366 if (i<IEEE80211_TX_MAX_RATES) 366 if (i<IEEE80211_TX_MAX_RATES)
@@ -424,12 +424,10 @@ void zd_mac_tx_failed(struct urb *urb)
424 first_idx = info->status.rates[0].idx; 424 first_idx = info->status.rates[0].idx;
425 ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates)); 425 ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates));
426 retries = &zd_retry_rates[first_idx]; 426 retries = &zd_retry_rates[first_idx];
427 if (retry < 0 || retry > retries->count) { 427 if (retry <= 0 || retry > retries->count)
428 continue; 428 continue;
429 }
430 429
431 ZD_ASSERT(0<=retry && retry<=retries->count); 430 final_idx = retries->rate[retry - 1];
432 final_idx = retries->rate[retry-1];
433 final_rate = zd_rates[final_idx].hw_value; 431 final_rate = zd_rates[final_idx].hw_value;
434 432
435 if (final_rate != tx_status->rate) { 433 if (final_rate != tx_status->rate) {