summaryrefslogtreecommitdiff
path: root/net/wireless
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-05-08 09:42:33 +0200
committerJohn W. Linville <linville@tuxdriver.com>2009-05-11 15:23:54 -0400
commit0b258582fef3a9b15b2372d99164859361faa8db (patch)
tree4467eb0ffbb199f7fd3aeb1418dfc31e7b344c25 /net/wireless
parentaa837e1d6bd1a71b3c30c7738b6c29d41512fe7d (diff)
cfg80211: fix wext iw_freq parsing
The function to parse a struct iw_freq has a stupid bug, it returns NULL when the channel cannot be found at all, but NULL is supposed to mean "auto". Fix this by checking the return value of ieee80211_get_channel() and returning ERR_PTR(-EINVAL) if it returned NULL (channel not found). This fixes an issue where you could say (in IBSS mode) iwconfig wlan0 channel 21 and it would use channel 1 instead because that's the first available channel with IBSS allowed (which is what the "auto" setting uses). Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/wext-compat.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 5ef82f2ca88f..abf6b0a047d8 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -296,22 +296,34 @@ EXPORT_SYMBOL_GPL(cfg80211_wext_siwmlme);
struct ieee80211_channel *cfg80211_wext_freq(struct wiphy *wiphy,
struct iw_freq *freq)
{
+ struct ieee80211_channel *chan;
+ int f;
+
+ /*
+ * Parse frequency - return NULL for auto and
+ * -EINVAL for impossible things.
+ */
if (freq->e == 0) {
if (freq->m < 0)
return NULL;
- else
- return ieee80211_get_channel(wiphy,
- ieee80211_channel_to_frequency(freq->m));
+ f = ieee80211_channel_to_frequency(freq->m);
} else {
int i, div = 1000000;
for (i = 0; i < freq->e; i++)
div /= 10;
- if (div > 0)
- return ieee80211_get_channel(wiphy, freq->m / div);
- else
+ if (div <= 0)
return ERR_PTR(-EINVAL);
+ f = freq->m / div;
}
+ /*
+ * Look up channel struct and return -EINVAL when
+ * it cannot be found.
+ */
+ chan = ieee80211_get_channel(wiphy, f);
+ if (!chan)
+ return ERR_PTR(-EINVAL);
+ return chan;
}
EXPORT_SYMBOL_GPL(cfg80211_wext_freq);