diff options
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/nl80211.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 88a530f707e6..130fc2561bac 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -1906,24 +1906,42 @@ static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info) | |||
1906 | int r; | 1906 | int r; |
1907 | char *data = NULL; | 1907 | char *data = NULL; |
1908 | 1908 | ||
1909 | if (!info->attrs[NL80211_ATTR_REG_ALPHA2]) | 1909 | /* |
1910 | return -EINVAL; | 1910 | * You should only get this when cfg80211 hasn't yet initialized |
1911 | * completely when built-in to the kernel right between the time | ||
1912 | * window between nl80211_init() and regulatory_init(), if that is | ||
1913 | * even possible. | ||
1914 | */ | ||
1915 | mutex_lock(&cfg80211_mutex); | ||
1916 | if (unlikely(!cfg80211_regdomain)) { | ||
1917 | r = -EINPROGRESS; | ||
1918 | goto out; | ||
1919 | } | ||
1920 | |||
1921 | if (!info->attrs[NL80211_ATTR_REG_ALPHA2]) { | ||
1922 | r = -EINVAL; | ||
1923 | goto out; | ||
1924 | } | ||
1911 | 1925 | ||
1912 | data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); | 1926 | data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]); |
1913 | 1927 | ||
1914 | #ifdef CONFIG_WIRELESS_OLD_REGULATORY | 1928 | #ifdef CONFIG_WIRELESS_OLD_REGULATORY |
1915 | /* We ignore world regdom requests with the old regdom setup */ | 1929 | /* We ignore world regdom requests with the old regdom setup */ |
1916 | if (is_world_regdom(data)) | 1930 | if (is_world_regdom(data)) { |
1917 | return -EINVAL; | 1931 | r = -EINVAL; |
1932 | goto out; | ||
1933 | } | ||
1918 | #endif | 1934 | #endif |
1919 | mutex_lock(&cfg80211_mutex); | ||
1920 | r = __regulatory_hint(NULL, REGDOM_SET_BY_USER, data, 0, ENVIRON_ANY); | 1935 | r = __regulatory_hint(NULL, REGDOM_SET_BY_USER, data, 0, ENVIRON_ANY); |
1921 | mutex_unlock(&cfg80211_mutex); | 1936 | /* |
1922 | /* This means the regulatory domain was already set, however | 1937 | * This means the regulatory domain was already set, however |
1923 | * we don't want to confuse userspace with a "successful error" | 1938 | * we don't want to confuse userspace with a "successful error" |
1924 | * message so lets just treat it as a success */ | 1939 | * message so lets just treat it as a success |
1940 | */ | ||
1925 | if (r == -EALREADY) | 1941 | if (r == -EALREADY) |
1926 | r = 0; | 1942 | r = 0; |
1943 | out: | ||
1944 | mutex_unlock(&cfg80211_mutex); | ||
1927 | return r; | 1945 | return r; |
1928 | } | 1946 | } |
1929 | 1947 | ||