Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ath9k: reject invalid antenna mask configurations
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32507 3c298f89-4303-0410-b956-a3cf2f4a3e73
- Loading branch information
nbd
committed
Jun 27, 2012
1 parent
3d1b9cd
commit 1a0f31f
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
package/mac80211/patches/561-ath9k_antenna_mask_validate.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- a/drivers/net/wireless/ath/ath9k/main.c | ||
+++ b/drivers/net/wireless/ath/ath9k/main.c | ||
@@ -1929,12 +1929,24 @@ static u32 fill_chainmask(u32 cap, u32 n | ||
return filled; | ||
} | ||
|
||
+static bool validate_antenna_mask(u32 val) | ||
+{ | ||
+ switch (val & 0x7) { | ||
+ case 0x1: | ||
+ case 0x3: | ||
+ case 0x7: | ||
+ return true; | ||
+ default: | ||
+ return false; | ||
+ } | ||
+} | ||
+ | ||
static int ath9k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) | ||
{ | ||
struct ath_softc *sc = hw->priv; | ||
struct ath_hw *ah = sc->sc_ah; | ||
|
||
- if (!rx_ant || !tx_ant) | ||
+ if (!validate_antenna_mask(rx_ant) || !validate_antenna_mask(tx_ant)) | ||
return -EINVAL; | ||
|
||
sc->ant_rx = rx_ant; |