Prevent a read of powInfo[-1] in the first iteration.

Signed-off-by: Roel Kluin <[email protected]>
---
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c 
b/drivers/net/wireless/ath/ath9k/eeprom.c
index ce0e86c..e67db2c 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -150,10 +150,10 @@ static 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;
                        }
@@ -268,10 +268,10 @@ static 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;
                                }
_______________________________________________
ath9k-devel mailing list
[email protected]
https://lists.ath9k.org/mailman/listinfo/ath9k-devel

Reply via email to