ath9k: Fix read buffer overflow
authorRoel Kluin <roel.kluin@gmail.com>
Fri, 7 Aug 2009 21:50:00 +0000 (23:50 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 28 Aug 2009 18:40:46 +0000 (14:40 -0400)
Prevent a read of powInfo[-1] in the first iteration.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/eeprom.c

index 958948bc73fda4cd9386c02dfb17f42ed4a90853..b6e52d0f8c489207e3ea4a78b3fc94a226f751a2 100644 (file)
@@ -143,10 +143,10 @@ void ath9k_hw_get_legacy_target_powers(struct ath_hw *ah,
                                                       IS_CHAN_2GHZ(chan))) {
                                matchIndex = i;
                                break;
-                       } else if ((freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
-                                                     IS_CHAN_2GHZ(chan))) &&
-                                  (freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
-                                                     IS_CHAN_2GHZ(chan)))) {
+                       } else if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
+                                               IS_CHAN_2GHZ(chan)) && i > 0 &&
+                                  freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
+                                               IS_CHAN_2GHZ(chan))) {
                                lowIndex = i - 1;
                                break;
                        }
@@ -198,10 +198,10 @@ void ath9k_hw_get_target_powers(struct ath_hw *ah,
                                matchIndex = i;
                                break;
                        } else
-                               if ((freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
-                                                      IS_CHAN_2GHZ(chan))) &&
-                                   (freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
-                                                      IS_CHAN_2GHZ(chan)))) {
+                               if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
+                                               IS_CHAN_2GHZ(chan)) && i > 0 &&
+                                   freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
+                                               IS_CHAN_2GHZ(chan))) {
                                        lowIndex = i - 1;
                                        break;
                                }