Commit d951c1dd authored by Luis R. Rodriguez's avatar Luis R. Rodriguez Committed by John W. Linville

cfg80211: do not kzalloc() again for a new request on __regulatory_hint

Since we already have a regulatory request from the workqueue use that
and avoid a new kzalloc()
Signed-off-by: default avatarLuis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 28da32d7
...@@ -1341,7 +1341,6 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by, ...@@ -1341,7 +1341,6 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
static int __regulatory_hint(struct wiphy *wiphy, static int __regulatory_hint(struct wiphy *wiphy,
struct regulatory_request *pending_request) struct regulatory_request *pending_request)
{ {
struct regulatory_request *request;
bool intersect = false; bool intersect = false;
int r = 0; int r = 0;
...@@ -1354,8 +1353,10 @@ static int __regulatory_hint(struct wiphy *wiphy, ...@@ -1354,8 +1353,10 @@ static int __regulatory_hint(struct wiphy *wiphy,
if (r == REG_INTERSECT) { if (r == REG_INTERSECT) {
if (pending_request->initiator == REGDOM_SET_BY_DRIVER) { if (pending_request->initiator == REGDOM_SET_BY_DRIVER) {
r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
if (r) if (r) {
kfree(pending_request);
return r; return r;
}
} }
intersect = true; intersect = true;
} else if (r) { } else if (r) {
...@@ -1367,30 +1368,24 @@ static int __regulatory_hint(struct wiphy *wiphy, ...@@ -1367,30 +1368,24 @@ static int __regulatory_hint(struct wiphy *wiphy,
if (r == -EALREADY && if (r == -EALREADY &&
pending_request->initiator == REGDOM_SET_BY_DRIVER) { pending_request->initiator == REGDOM_SET_BY_DRIVER) {
r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
if (r) if (r) {
kfree(pending_request);
return r; return r;
}
r = -EALREADY; r = -EALREADY;
goto new_request; goto new_request;
} }
kfree(pending_request);
return r; return r;
} }
new_request: new_request:
request = kzalloc(sizeof(struct regulatory_request), kfree(last_request);
GFP_KERNEL);
if (!request)
return -ENOMEM;
request->alpha2[0] = pending_request->alpha2[0]; last_request = pending_request;
request->alpha2[1] = pending_request->alpha2[1]; last_request->intersect = intersect;
request->initiator = pending_request->initiator;
request->wiphy_idx = pending_request->wiphy_idx;
request->intersect = intersect;
request->country_ie_checksum = pending_request->country_ie_checksum;
request->country_ie_env = pending_request->country_ie_env;
kfree(last_request); pending_request = NULL;
last_request = request;
/* When r == REG_INTERSECT we do need to call CRDA */ /* When r == REG_INTERSECT we do need to call CRDA */
if (r < 0) if (r < 0)
...@@ -1406,11 +1401,11 @@ new_request: ...@@ -1406,11 +1401,11 @@ new_request:
* *
* to intersect with the static rd * to intersect with the static rd
*/ */
return call_crda(request->alpha2); return call_crda(last_request->alpha2);
} }
/* This currently only processes user and driver regulatory hints */ /* This currently only processes user and driver regulatory hints */
static int reg_process_hint(struct regulatory_request *reg_request) static void reg_process_hint(struct regulatory_request *reg_request)
{ {
int r = 0; int r = 0;
struct wiphy *wiphy = NULL; struct wiphy *wiphy = NULL;
...@@ -1424,7 +1419,7 @@ static int reg_process_hint(struct regulatory_request *reg_request) ...@@ -1424,7 +1419,7 @@ static int reg_process_hint(struct regulatory_request *reg_request)
if (reg_request->initiator == REGDOM_SET_BY_DRIVER && if (reg_request->initiator == REGDOM_SET_BY_DRIVER &&
!wiphy) { !wiphy) {
r = -ENODEV; kfree(reg_request);
goto out; goto out;
} }
...@@ -1434,18 +1429,12 @@ static int reg_process_hint(struct regulatory_request *reg_request) ...@@ -1434,18 +1429,12 @@ static int reg_process_hint(struct regulatory_request *reg_request)
wiphy_update_regulatory(wiphy, reg_request->initiator); wiphy_update_regulatory(wiphy, reg_request->initiator);
out: out:
mutex_unlock(&cfg80211_mutex); mutex_unlock(&cfg80211_mutex);
if (r == -EALREADY)
r = 0;
return r;
} }
/* Processes regulatory hints, this is all the REGDOM_SET_BY_* */ /* Processes regulatory hints, this is all the REGDOM_SET_BY_* */
static void reg_process_pending_hints(void) static void reg_process_pending_hints(void)
{ {
struct regulatory_request *reg_request; struct regulatory_request *reg_request;
int r;
spin_lock(&reg_requests_lock); spin_lock(&reg_requests_lock);
while (!list_empty(&reg_requests_list)) { while (!list_empty(&reg_requests_list)) {
...@@ -1453,20 +1442,9 @@ static void reg_process_pending_hints(void) ...@@ -1453,20 +1442,9 @@ static void reg_process_pending_hints(void)
struct regulatory_request, struct regulatory_request,
list); list);
list_del_init(&reg_request->list); list_del_init(&reg_request->list);
spin_unlock(&reg_requests_lock);
r = reg_process_hint(reg_request); spin_unlock(&reg_requests_lock);
#ifdef CONFIG_CFG80211_REG_DEBUG reg_process_hint(reg_request);
if (r && (reg_request->initiator == REGDOM_SET_BY_DRIVER ||
reg_request->initiator == REGDOM_SET_BY_COUNTRY_IE))
printk(KERN_ERR "cfg80211: wiphy_idx %d sent a "
"regulatory hint for %c%c but now has "
"gone fishing, ignoring request\n",
reg_request->wiphy_idx,
reg_request->alpha2[0],
reg_request->alpha2[1]);
#endif
kfree(reg_request);
spin_lock(&reg_requests_lock); spin_lock(&reg_requests_lock);
} }
spin_unlock(&reg_requests_lock); spin_unlock(&reg_requests_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment