aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/nl80211.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r--net/wireless/nl80211.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f1b0774d098b..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
1182static 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
1182static int __nl80211_set_channel(struct cfg80211_registered_device *rdev, 1203static 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
@@ -4918,12 +4933,7 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
4918 if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { 4933 if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
4919 enum nl80211_channel_type channel_type; 4934 enum nl80211_channel_type channel_type;
4920 4935
4921 channel_type = nla_get_u32( 4936 if (!nl80211_valid_channel_type(info, &channel_type))
4922 info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
4923 if (channel_type != NL80211_CHAN_NO_HT &&
4924 channel_type != NL80211_CHAN_HT20 &&
4925 channel_type != NL80211_CHAN_HT40MINUS &&
4926 channel_type != NL80211_CHAN_HT40PLUS)
4927 return -EINVAL; 4937 return -EINVAL;
4928 4938
4929 if (channel_type != NL80211_CHAN_NO_HT && 4939 if (channel_type != NL80211_CHAN_NO_HT &&
@@ -5491,15 +5501,9 @@ static int nl80211_remain_on_channel(struct sk_buff *skb,
5491 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL)) 5501 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL))
5492 return -EOPNOTSUPP; 5502 return -EOPNOTSUPP;
5493 5503
5494 if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { 5504 if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE] &&
5495 channel_type = nla_get_u32( 5505 !nl80211_valid_channel_type(info, &channel_type))
5496 info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]); 5506 return -EINVAL;
5497 if (channel_type != NL80211_CHAN_NO_HT &&
5498 channel_type != NL80211_CHAN_HT20 &&
5499 channel_type != NL80211_CHAN_HT40PLUS &&
5500 channel_type != NL80211_CHAN_HT40MINUS)
5501 return -EINVAL;
5502 }
5503 5507
5504 freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]); 5508 freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]);
5505 chan = rdev_freq_to_chan(rdev, freq, channel_type); 5509 chan = rdev_freq_to_chan(rdev, freq, channel_type);
@@ -5770,12 +5774,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
5770 } 5774 }
5771 5775
5772 if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { 5776 if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
5773 channel_type = nla_get_u32( 5777 if (!nl80211_valid_channel_type(info, &channel_type))
5774 info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
5775 if (channel_type != NL80211_CHAN_NO_HT &&
5776 channel_type != NL80211_CHAN_HT20 &&
5777 channel_type != NL80211_CHAN_HT40PLUS &&
5778 channel_type != NL80211_CHAN_HT40MINUS)
5779 return -EINVAL; 5778 return -EINVAL;
5780 channel_type_valid = true; 5779 channel_type_valid = true;
5781 } 5780 }