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>
This commit is contained in:
committed by
John W. Linville
parent
aa837e1d6b
commit
0b258582fe
@@ -296,22 +296,34 @@ EXPORT_SYMBOL_GPL(cfg80211_wext_siwmlme);
|
|||||||
struct ieee80211_channel *cfg80211_wext_freq(struct wiphy *wiphy,
|
struct ieee80211_channel *cfg80211_wext_freq(struct wiphy *wiphy,
|
||||||
struct iw_freq *freq)
|
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->e == 0) {
|
||||||
if (freq->m < 0)
|
if (freq->m < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
else
|
f = ieee80211_channel_to_frequency(freq->m);
|
||||||
return ieee80211_get_channel(wiphy,
|
|
||||||
ieee80211_channel_to_frequency(freq->m));
|
|
||||||
} else {
|
} else {
|
||||||
int i, div = 1000000;
|
int i, div = 1000000;
|
||||||
for (i = 0; i < freq->e; i++)
|
for (i = 0; i < freq->e; i++)
|
||||||
div /= 10;
|
div /= 10;
|
||||||
if (div > 0)
|
if (div <= 0)
|
||||||
return ieee80211_get_channel(wiphy, freq->m / div);
|
|
||||||
else
|
|
||||||
return ERR_PTR(-EINVAL);
|
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);
|
EXPORT_SYMBOL_GPL(cfg80211_wext_freq);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user