Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 351741
b: refs/heads/master
c: 6913b49
h: refs/heads/master
i:
  351739: 0fbe1c4
v: v3
  • Loading branch information
Johannes Berg committed Jan 3, 2013
1 parent d4102c6 commit f878a63
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 540f6f2cc545da9ae2baa9faa3152fc550bedb57
refs/heads/master: 6913b49a5071064f49f7a74b432286fa735f7612
18 changes: 6 additions & 12 deletions trunk/net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -4265,21 +4265,12 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
return -EINVAL;
}

mutex_lock(&cfg80211_mutex);

if (!reg_is_valid_request(alpha2)) {
r = -EINVAL;
goto bad_reg;
}

size_of_regd = sizeof(struct ieee80211_regdomain) +
num_rules * sizeof(struct ieee80211_reg_rule);

rd = kzalloc(size_of_regd, GFP_KERNEL);
if (!rd) {
r = -ENOMEM;
goto bad_reg;
}
if (!rd)
return -ENOMEM;

rd->n_reg_rules = num_rules;
rd->alpha2[0] = alpha2[0];
Expand Down Expand Up @@ -4309,11 +4300,14 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
}
}

mutex_lock(&cfg80211_mutex);

r = set_regdom(rd);
/* set_regdom took ownership */
rd = NULL;
mutex_unlock(&cfg80211_mutex);

bad_reg:
mutex_unlock(&cfg80211_mutex);
kfree(rd);
return r;
}
Expand Down
21 changes: 11 additions & 10 deletions trunk/net/wireless/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,16 @@ static int call_crda(const char *alpha2)
return kobject_uevent(&reg_pdev->dev.kobj, KOBJ_CHANGE);
}

/* Used by nl80211 before kmalloc'ing our regulatory domain */
bool reg_is_valid_request(const char *alpha2)
static bool reg_is_valid_request(const char *alpha2)
{
assert_reg_lock();

if (!last_request)
return false;

if (last_request->processed)
return false;

return alpha2_equal(last_request->alpha2, alpha2);
}

Expand Down Expand Up @@ -1470,6 +1474,7 @@ __regulatory_hint(struct wiphy *wiphy,

last_request = pending_request;
last_request->intersect = intersect;
last_request->processed = false;

pending_request = NULL;

Expand Down Expand Up @@ -2060,11 +2065,13 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
const struct ieee80211_regdomain *regd;
const struct ieee80211_regdomain *intersected_rd = NULL;
struct wiphy *request_wiphy;

/* Some basic sanity checks first */

if (!reg_is_valid_request(rd->alpha2))
return -EINVAL;

if (is_world_regdom(rd->alpha2)) {
if (WARN_ON(!reg_is_valid_request(rd->alpha2)))
return -EINVAL;
update_world_regdomain(rd);
return 0;
}
Expand All @@ -2073,9 +2080,6 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
!is_unknown_alpha2(rd->alpha2))
return -EINVAL;

if (!last_request)
return -EINVAL;

/*
* Lets only bother proceeding on the same alpha2 if the current
* rd is non static (it means CRDA was present and was used last)
Expand All @@ -2097,9 +2101,6 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
* internal EEPROM data
*/

if (WARN_ON(!reg_is_valid_request(rd->alpha2)))
return -EINVAL;

if (!is_valid_rd(rd)) {
pr_err("Invalid regulatory domain detected:\n");
print_regdomain_info(rd);
Expand Down
1 change: 0 additions & 1 deletion trunk/net/wireless/reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
extern const struct ieee80211_regdomain *cfg80211_regdomain;

bool is_world_regdom(const char *alpha2);
bool reg_is_valid_request(const char *alpha2);
bool reg_supported_dfs_region(u8 dfs_region);

int regulatory_hint_user(const char *alpha2,
Expand Down

0 comments on commit f878a63

Please sign in to comment.