Merge tag 'xfs-4.19-merge-7' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[sfrench/cifs-2.6.git] / net / wireless / core.c
index 48e8097339ab44cca29bc9bbc938b58ea3a43333..a88551f3bc43f201cfd09ec7dc93ed2a42e93cf8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2006-2010         Johannes Berg <johannes@sipsolutions.net>
  * Copyright 2013-2014  Intel Mobile Communications GmbH
- * Copyright 2015      Intel Deutschland GmbH
+ * Copyright 2015-2017 Intel Deutschland GmbH
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -744,6 +744,8 @@ int wiphy_register(struct wiphy *wiphy)
 
        /* sanity check supported bands/channels */
        for (band = 0; band < NUM_NL80211_BANDS; band++) {
+               u16 types = 0;
+
                sband = wiphy->bands[band];
                if (!sband)
                        continue;
@@ -788,6 +790,23 @@ int wiphy_register(struct wiphy *wiphy)
                        sband->channels[i].band = band;
                }
 
+               for (i = 0; i < sband->n_iftype_data; i++) {
+                       const struct ieee80211_sband_iftype_data *iftd;
+
+                       iftd = &sband->iftype_data[i];
+
+                       if (WARN_ON(!iftd->types_mask))
+                               return -EINVAL;
+                       if (WARN_ON(types & iftd->types_mask))
+                               return -EINVAL;
+
+                       /* at least one piece of information must be present */
+                       if (WARN_ON(!iftd->he_cap.has_he))
+                               return -EINVAL;
+
+                       types |= iftd->types_mask;
+               }
+
                have_band = true;
        }