diff options
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r-- | net/wireless/nl80211.c | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index b67b1114e25a..206465dc0cab 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -1179,6 +1179,27 @@ static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev) | |||
1179 | wdev->iftype == NL80211_IFTYPE_P2P_GO; | 1179 | wdev->iftype == NL80211_IFTYPE_P2P_GO; |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | static bool nl80211_valid_channel_type(struct genl_info *info, | ||
1183 | enum nl80211_channel_type *channel_type) | ||
1184 | { | ||
1185 | enum nl80211_channel_type tmp; | ||
1186 | |||
1187 | if (!info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) | ||
1188 | return false; | ||
1189 | |||
1190 | tmp = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]); | ||
1191 | if (tmp != NL80211_CHAN_NO_HT && | ||
1192 | tmp != NL80211_CHAN_HT20 && | ||
1193 | tmp != NL80211_CHAN_HT40PLUS && | ||
1194 | tmp != NL80211_CHAN_HT40MINUS) | ||
1195 | return false; | ||
1196 | |||
1197 | if (channel_type) | ||
1198 | *channel_type = tmp; | ||
1199 | |||
1200 | return true; | ||
1201 | } | ||
1202 | |||
1182 | static int __nl80211_set_channel(struct cfg80211_registered_device *rdev, | 1203 | static int __nl80211_set_channel(struct cfg80211_registered_device *rdev, |
1183 | struct wireless_dev *wdev, | 1204 | struct wireless_dev *wdev, |
1184 | struct genl_info *info) | 1205 | struct genl_info *info) |
@@ -1193,15 +1214,9 @@ static int __nl80211_set_channel(struct cfg80211_registered_device *rdev, | |||
1193 | if (!nl80211_can_set_dev_channel(wdev)) | 1214 | if (!nl80211_can_set_dev_channel(wdev)) |
1194 | return -EOPNOTSUPP; | 1215 | return -EOPNOTSUPP; |
1195 | 1216 | ||
1196 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { | 1217 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE] && |
1197 | channel_type = nla_get_u32(info->attrs[ | 1218 | !nl80211_valid_channel_type(info, &channel_type)) |
1198 | NL80211_ATTR_WIPHY_CHANNEL_TYPE]); | 1219 | return -EINVAL; |
1199 | if (channel_type != NL80211_CHAN_NO_HT && | ||
1200 | channel_type != NL80211_CHAN_HT20 && | ||
1201 | channel_type != NL80211_CHAN_HT40PLUS && | ||
1202 | channel_type != NL80211_CHAN_HT40MINUS) | ||
1203 | return -EINVAL; | ||
1204 | } | ||
1205 | 1220 | ||
1206 | freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]); | 1221 | freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]); |
1207 | 1222 | ||
@@ -2410,10 +2425,16 @@ static int parse_station_flags(struct genl_info *info, | |||
2410 | return -EINVAL; | 2425 | return -EINVAL; |
2411 | } | 2426 | } |
2412 | 2427 | ||
2413 | for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++) | 2428 | for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++) { |
2414 | if (flags[flag]) | 2429 | if (flags[flag]) { |
2415 | params->sta_flags_set |= (1<<flag); | 2430 | params->sta_flags_set |= (1<<flag); |
2416 | 2431 | ||
2432 | /* no longer support new API additions in old API */ | ||
2433 | if (flag > NL80211_STA_FLAG_MAX_OLD_API) | ||
2434 | return -EINVAL; | ||
2435 | } | ||
2436 | } | ||
2437 | |||
2417 | return 0; | 2438 | return 0; |
2418 | } | 2439 | } |
2419 | 2440 | ||
@@ -4912,12 +4933,7 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) | |||
4912 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { | 4933 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { |
4913 | enum nl80211_channel_type channel_type; | 4934 | enum nl80211_channel_type channel_type; |
4914 | 4935 | ||
4915 | channel_type = nla_get_u32( | 4936 | if (!nl80211_valid_channel_type(info, &channel_type)) |
4916 | info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]); | ||
4917 | if (channel_type != NL80211_CHAN_NO_HT && | ||
4918 | channel_type != NL80211_CHAN_HT20 && | ||
4919 | channel_type != NL80211_CHAN_HT40MINUS && | ||
4920 | channel_type != NL80211_CHAN_HT40PLUS) | ||
4921 | return -EINVAL; | 4937 | return -EINVAL; |
4922 | 4938 | ||
4923 | if (channel_type != NL80211_CHAN_NO_HT && | 4939 | if (channel_type != NL80211_CHAN_NO_HT && |
@@ -5485,15 +5501,9 @@ static int nl80211_remain_on_channel(struct sk_buff *skb, | |||
5485 | !(rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL)) | 5501 | !(rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL)) |
5486 | return -EOPNOTSUPP; | 5502 | return -EOPNOTSUPP; |
5487 | 5503 | ||
5488 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { | 5504 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE] && |
5489 | channel_type = nla_get_u32( | 5505 | !nl80211_valid_channel_type(info, &channel_type)) |
5490 | info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]); | 5506 | return -EINVAL; |
5491 | if (channel_type != NL80211_CHAN_NO_HT && | ||
5492 | channel_type != NL80211_CHAN_HT20 && | ||
5493 | channel_type != NL80211_CHAN_HT40PLUS && | ||
5494 | channel_type != NL80211_CHAN_HT40MINUS) | ||
5495 | return -EINVAL; | ||
5496 | } | ||
5497 | 5507 | ||
5498 | freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]); | 5508 | freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]); |
5499 | chan = rdev_freq_to_chan(rdev, freq, channel_type); | 5509 | chan = rdev_freq_to_chan(rdev, freq, channel_type); |
@@ -5764,12 +5774,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) | |||
5764 | } | 5774 | } |
5765 | 5775 | ||
5766 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { | 5776 | if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { |
5767 | channel_type = nla_get_u32( | 5777 | if (!nl80211_valid_channel_type(info, &channel_type)) |
5768 | info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]); | ||
5769 | if (channel_type != NL80211_CHAN_NO_HT && | ||
5770 | channel_type != NL80211_CHAN_HT20 && | ||
5771 | channel_type != NL80211_CHAN_HT40PLUS && | ||
5772 | channel_type != NL80211_CHAN_HT40MINUS) | ||
5773 | return -EINVAL; | 5778 | return -EINVAL; |
5774 | channel_type_valid = true; | 5779 | channel_type_valid = true; |
5775 | } | 5780 | } |