Commit 30dd3edf authored by Johannes Berg's avatar Johannes Berg

mac80211: don't hang on to sched_scan_ies

There's no need to keep a copy of the scheduled
scan IEs after the driver has been told, if it
requires a copy it must make one. Therefore, we
can move sched_scan_ies into the function.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 944b9e37
...@@ -970,7 +970,6 @@ struct ieee80211_local { ...@@ -970,7 +970,6 @@ struct ieee80211_local {
int scan_channel_idx; int scan_channel_idx;
int scan_ies_len; int scan_ies_len;
struct ieee80211_sched_scan_ies sched_scan_ies;
struct work_struct sched_scan_stopped_work; struct work_struct sched_scan_stopped_work;
struct ieee80211_sub_if_data __rcu *sched_scan_sdata; struct ieee80211_sub_if_data __rcu *sched_scan_sdata;
......
...@@ -917,6 +917,7 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, ...@@ -917,6 +917,7 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
struct cfg80211_sched_scan_request *req) struct cfg80211_sched_scan_request *req)
{ {
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
struct ieee80211_sched_scan_ies sched_scan_ies;
int ret, i; int ret, i;
mutex_lock(&local->mtx); mutex_lock(&local->mtx);
...@@ -935,33 +936,28 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, ...@@ -935,33 +936,28 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
if (!local->hw.wiphy->bands[i]) if (!local->hw.wiphy->bands[i])
continue; continue;
local->sched_scan_ies.ie[i] = kzalloc(2 + sched_scan_ies.ie[i] = kzalloc(2 + IEEE80211_MAX_SSID_LEN +
IEEE80211_MAX_SSID_LEN +
local->scan_ies_len + local->scan_ies_len +
req->ie_len, req->ie_len,
GFP_KERNEL); GFP_KERNEL);
if (!local->sched_scan_ies.ie[i]) { if (!sched_scan_ies.ie[i]) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_free; goto out_free;
} }
local->sched_scan_ies.len[i] = sched_scan_ies.len[i] =
ieee80211_build_preq_ies(local, ieee80211_build_preq_ies(local, sched_scan_ies.ie[i],
local->sched_scan_ies.ie[i],
req->ie, req->ie_len, i, req->ie, req->ie_len, i,
(u32) -1, 0); (u32) -1, 0);
} }
ret = drv_sched_scan_start(local, sdata, req, ret = drv_sched_scan_start(local, sdata, req, &sched_scan_ies);
&local->sched_scan_ies); if (ret == 0)
if (ret == 0) {
rcu_assign_pointer(local->sched_scan_sdata, sdata); rcu_assign_pointer(local->sched_scan_sdata, sdata);
goto out;
}
out_free: out_free:
while (i > 0) while (i > 0)
kfree(local->sched_scan_ies.ie[--i]); kfree(sched_scan_ies.ie[--i]);
out: out:
mutex_unlock(&local->mtx); mutex_unlock(&local->mtx);
return ret; return ret;
...@@ -970,7 +966,7 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, ...@@ -970,7 +966,7 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata) int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata)
{ {
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
int ret = 0, i; int ret = 0;
mutex_lock(&local->mtx); mutex_lock(&local->mtx);
...@@ -979,12 +975,9 @@ int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata) ...@@ -979,12 +975,9 @@ int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata)
goto out; goto out;
} }
if (rcu_access_pointer(local->sched_scan_sdata)) { if (rcu_access_pointer(local->sched_scan_sdata))
for (i = 0; i < IEEE80211_NUM_BANDS; i++)
kfree(local->sched_scan_ies.ie[i]);
drv_sched_scan_stop(local, sdata); drv_sched_scan_stop(local, sdata);
}
out: out:
mutex_unlock(&local->mtx); mutex_unlock(&local->mtx);
...@@ -1006,7 +999,6 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work) ...@@ -1006,7 +999,6 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work)
struct ieee80211_local *local = struct ieee80211_local *local =
container_of(work, struct ieee80211_local, container_of(work, struct ieee80211_local,
sched_scan_stopped_work); sched_scan_stopped_work);
int i;
mutex_lock(&local->mtx); mutex_lock(&local->mtx);
...@@ -1015,9 +1007,6 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work) ...@@ -1015,9 +1007,6 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work)
return; return;
} }
for (i = 0; i < IEEE80211_NUM_BANDS; i++)
kfree(local->sched_scan_ies.ie[i]);
rcu_assign_pointer(local->sched_scan_sdata, NULL); rcu_assign_pointer(local->sched_scan_sdata, NULL);
mutex_unlock(&local->mtx); mutex_unlock(&local->mtx);
......
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