Merge tag 'mac80211-next-for-davem-2016-06-09' of git://git.kernel.org/pub/scm/linux...
[cascardo/linux.git] / net / wireless / core.c
index ecca389..39d9abd 100644 (file)
@@ -748,6 +748,36 @@ int wiphy_register(struct wiphy *wiphy)
                nl80211_send_reg_change_event(&request);
        }
 
+       /* Check that nobody globally advertises any capabilities they do not
+        * advertise on all possible interface types.
+        */
+       if (wiphy->extended_capabilities_len &&
+           wiphy->num_iftype_ext_capab &&
+           wiphy->iftype_ext_capab) {
+               u8 supported_on_all, j;
+               const struct wiphy_iftype_ext_capab *capab;
+
+               capab = wiphy->iftype_ext_capab;
+               for (j = 0; j < wiphy->extended_capabilities_len; j++) {
+                       if (capab[0].extended_capabilities_len > j)
+                               supported_on_all =
+                                       capab[0].extended_capabilities[j];
+                       else
+                               supported_on_all = 0x00;
+                       for (i = 1; i < wiphy->num_iftype_ext_capab; i++) {
+                               if (j >= capab[i].extended_capabilities_len) {
+                                       supported_on_all = 0x00;
+                                       break;
+                               }
+                               supported_on_all &=
+                                       capab[i].extended_capabilities[j];
+                       }
+                       if (WARN_ON(wiphy->extended_capabilities[j] &
+                                   ~supported_on_all))
+                               break;
+               }
+       }
+
        rdev->wiphy.registered = true;
        rtnl_unlock();