summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2010-10-09 02:39:30 +0200
committerJohn W. Linville2010-10-11 21:04:21 +0200
commitcac4220b2e93e6344f987581d52d5bd71ff2cc0e (patch)
treed089cca561a5fe1237a1f2a80589c7819ed3abe8
parentcfg80211: add channel utilization stats to the survey command (diff)
downloadkernel-qcow2-linux-cac4220b2e93e6344f987581d52d5bd71ff2cc0e.tar.gz
kernel-qcow2-linux-cac4220b2e93e6344f987581d52d5bd71ff2cc0e.tar.xz
kernel-qcow2-linux-cac4220b2e93e6344f987581d52d5bd71ff2cc0e.zip
ath9k: add compile time checking for the size of the channel list
This prevents random memory corruption if the number of channels ever gets changed without an update to the internal channel array size. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h4
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c4
2 files changed, 7 insertions, 1 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 7f696c82ca0a..6b9233472fbf 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -61,6 +61,8 @@
#define ATH9K_RSSI_BAD -128
+#define ATH9K_NUM_CHANNELS 38
+
/* Register read/write primitives */
#define REG_WRITE(_ah, _reg, _val) \
ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
@@ -618,7 +620,7 @@ struct ath_hw {
struct ath9k_hw_version hw_version;
struct ath9k_ops_config config;
struct ath9k_hw_capabilities caps;
- struct ath9k_channel channels[38];
+ struct ath9k_channel channels[ATH9K_NUM_CHANNELS];
struct ath9k_channel *curchan;
union {
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index d76003c06fe4..a4c5ed41b176 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -481,6 +481,10 @@ static int ath9k_init_channels_rates(struct ath_softc *sc)
{
void *channels;
+ BUILD_BUG_ON(ARRAY_SIZE(ath9k_2ghz_chantable) +
+ ARRAY_SIZE(ath9k_5ghz_chantable) !=
+ ATH9K_NUM_CHANNELS);
+
if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes)) {
channels = kmemdup(ath9k_2ghz_chantable,
sizeof(ath9k_2ghz_chantable), GFP_KERNEL);