Commit 7d969204 authored by Bob Copeland's avatar Bob Copeland Committed by John W. Linville

ath5k: fix off-by-one in gpio checks

Sanity checks against AR5K_NUM_GPIO were all broken.  This doesn't
currently cause any problems since we only use the first four gpios.

Changes-licensed-under: ISC
Reported-by: default avatarAndreas Mohr <andi@lisas.de>
Signed-off-by: default avatarBob Copeland <me@bobcopeland.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 63649b6c
...@@ -83,7 +83,7 @@ void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state) ...@@ -83,7 +83,7 @@ void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state)
int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio) int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio)
{ {
ATH5K_TRACE(ah->ah_sc); ATH5K_TRACE(ah->ah_sc);
if (gpio > AR5K_NUM_GPIO) if (gpio >= AR5K_NUM_GPIO)
return -EINVAL; return -EINVAL;
ath5k_hw_reg_write(ah, ath5k_hw_reg_write(ah,
...@@ -99,7 +99,7 @@ int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio) ...@@ -99,7 +99,7 @@ int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio)
int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio) int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio)
{ {
ATH5K_TRACE(ah->ah_sc); ATH5K_TRACE(ah->ah_sc);
if (gpio > AR5K_NUM_GPIO) if (gpio >= AR5K_NUM_GPIO)
return -EINVAL; return -EINVAL;
ath5k_hw_reg_write(ah, ath5k_hw_reg_write(ah,
...@@ -115,7 +115,7 @@ int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio) ...@@ -115,7 +115,7 @@ int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio)
u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio) u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio)
{ {
ATH5K_TRACE(ah->ah_sc); ATH5K_TRACE(ah->ah_sc);
if (gpio > AR5K_NUM_GPIO) if (gpio >= AR5K_NUM_GPIO)
return 0xffffffff; return 0xffffffff;
/* GPIO input magic */ /* GPIO input magic */
...@@ -131,7 +131,7 @@ int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val) ...@@ -131,7 +131,7 @@ int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val)
u32 data; u32 data;
ATH5K_TRACE(ah->ah_sc); ATH5K_TRACE(ah->ah_sc);
if (gpio > AR5K_NUM_GPIO) if (gpio >= AR5K_NUM_GPIO)
return -EINVAL; return -EINVAL;
/* GPIO output magic */ /* GPIO output magic */
...@@ -154,7 +154,7 @@ void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, ...@@ -154,7 +154,7 @@ void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio,
u32 data; u32 data;
ATH5K_TRACE(ah->ah_sc); ATH5K_TRACE(ah->ah_sc);
if (gpio > AR5K_NUM_GPIO) if (gpio >= AR5K_NUM_GPIO)
return; return;
/* /*
......
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