cfg80211: correctly check ad-hoc channels
authorArik Nemtsov <arik@wizery.com>
Wed, 3 Dec 2014 16:08:17 +0000 (18:08 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 12 Dec 2014 12:40:38 +0000 (13:40 +0100)
Ad-hoc requires beaconing for regulatory purposes. Validate that the
channel is valid for beaconing, and not only enabled.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Reviewed-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/reg.c

index c9f5ad5d5d942b95f84ebb4708e26ab8e4ba656e..7b8309840d4e1b499cc7efbd73bc07222c0d5def 100644 (file)
@@ -1546,12 +1546,18 @@ static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev)
                if (!wdev->beacon_interval)
                        goto out;
 
+               ret = cfg80211_reg_can_beacon(wiphy,
+                                             &wdev->chandef, wdev->iftype);
+               break;
+       case NL80211_IFTYPE_ADHOC:
+               if (!wdev->ssid_len)
+                       goto out;
+
                ret = cfg80211_reg_can_beacon(wiphy,
                                              &wdev->chandef, wdev->iftype);
                break;
        case NL80211_IFTYPE_STATION:
        case NL80211_IFTYPE_P2P_CLIENT:
-       case NL80211_IFTYPE_ADHOC:
                if (!wdev->current_bss ||
                    !wdev->current_bss->pub.channel)
                        goto out;