ath5k: warn and correct rate for unknown hw rate indexes
authorBob Copeland <me@bobcopeland.com>
Tue, 3 Mar 2009 02:55:18 +0000 (21:55 -0500)
committerJohn W. Linville <linville@tuxdriver.com>
Sat, 28 Mar 2009 00:13:18 +0000 (20:13 -0400)
ath5k sets up a mapping table from the hardware rate index to
the rate index used by mac80211; however, we have seen some
received frames with incorrect rate indexes.  Such frames
normally get dropped with a warning in __ieee80211_rx(),
but it doesn't include enough information to track down the
error.

This patch adds a warning to hw_to_driver_rix for any lookups
that result in a rate index of -1, then returns a valid rate so
the frame can be processed.

Changes-licensed-under: 3-Clause-BSD

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Cc: stable@kernel.org
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath5k/base.c
drivers/net/wireless/ath5k/base.h

index f28b86c5d346dd967e53cb3c3d06fed91184220b..6580df2f74433495019c22b744d02f96a323d4a3 100644 (file)
@@ -1088,9 +1088,18 @@ ath5k_mode_setup(struct ath5k_softc *sc)
 static inline int
 ath5k_hw_to_driver_rix(struct ath5k_softc *sc, int hw_rix)
 {
-       WARN(hw_rix < 0 || hw_rix >= AR5K_MAX_RATES,
-                       "hw_rix out of bounds: %x\n", hw_rix);
-       return sc->rate_idx[sc->curband->band][hw_rix];
+       int rix;
+
+       /* return base rate on errors */
+       if (WARN(hw_rix < 0 || hw_rix >= AR5K_MAX_RATES,
+                       "hw_rix out of bounds: %x\n", hw_rix))
+               return 0;
+
+       rix = sc->rate_idx[sc->curband->band][hw_rix];
+       if (WARN(rix < 0, "invalid hw_rix: %x\n", hw_rix))
+               rix = 0;
+
+       return rix;
 }
 
 /***************\
index 20e0d14b41eca221710c9fc6fa981c239f31c5f4..822956114cd767781ec6546814d6c2cf8f0047c0 100644 (file)
@@ -112,7 +112,7 @@ struct ath5k_softc {
        struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
        struct ieee80211_channel channels[ATH_CHAN_MAX];
        struct ieee80211_rate   rates[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
-       u8                      rate_idx[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
+       s8                      rate_idx[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
        enum nl80211_iftype     opmode;
        struct ath5k_hw         *ah;            /* Atheros HW */