diff options
author | Johannes Berg <johannes.berg@intel.com> | 2012-09-04 13:15:01 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2012-09-06 09:56:35 -0400 |
commit | 30dd3edf97abda301150c8cf26fed21e53e3a9ce (patch) | |
tree | 595b08d29e6b5c2358228783d5f825d6dc4f61cf /net/mac80211/scan.c | |
parent | 944b9e375d89271c39995d363f62cb91734fae5f (diff) |
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: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/scan.c')
-rw-r--r-- | net/mac80211/scan.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 740e414d44f4..e9b19294dd45 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c | |||
@@ -917,6 +917,7 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, | |||
917 | struct cfg80211_sched_scan_request *req) | 917 | struct cfg80211_sched_scan_request *req) |
918 | { | 918 | { |
919 | struct ieee80211_local *local = sdata->local; | 919 | struct ieee80211_local *local = sdata->local; |
920 | struct ieee80211_sched_scan_ies sched_scan_ies; | ||
920 | int ret, i; | 921 | int ret, i; |
921 | 922 | ||
922 | mutex_lock(&local->mtx); | 923 | mutex_lock(&local->mtx); |
@@ -935,33 +936,28 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, | |||
935 | if (!local->hw.wiphy->bands[i]) | 936 | if (!local->hw.wiphy->bands[i]) |
936 | continue; | 937 | continue; |
937 | 938 | ||
938 | local->sched_scan_ies.ie[i] = kzalloc(2 + | 939 | sched_scan_ies.ie[i] = kzalloc(2 + IEEE80211_MAX_SSID_LEN + |
939 | IEEE80211_MAX_SSID_LEN + | 940 | local->scan_ies_len + |
940 | local->scan_ies_len + | 941 | req->ie_len, |
941 | req->ie_len, | 942 | GFP_KERNEL); |
942 | GFP_KERNEL); | 943 | if (!sched_scan_ies.ie[i]) { |
943 | if (!local->sched_scan_ies.ie[i]) { | ||
944 | ret = -ENOMEM; | 944 | ret = -ENOMEM; |
945 | goto out_free; | 945 | goto out_free; |
946 | } | 946 | } |
947 | 947 | ||
948 | local->sched_scan_ies.len[i] = | 948 | sched_scan_ies.len[i] = |
949 | ieee80211_build_preq_ies(local, | 949 | ieee80211_build_preq_ies(local, sched_scan_ies.ie[i], |
950 | local->sched_scan_ies.ie[i], | ||
951 | req->ie, req->ie_len, i, | 950 | req->ie, req->ie_len, i, |
952 | (u32) -1, 0); | 951 | (u32) -1, 0); |
953 | } | 952 | } |
954 | 953 | ||
955 | ret = drv_sched_scan_start(local, sdata, req, | 954 | ret = drv_sched_scan_start(local, sdata, req, &sched_scan_ies); |
956 | &local->sched_scan_ies); | 955 | if (ret == 0) |
957 | if (ret == 0) { | ||
958 | rcu_assign_pointer(local->sched_scan_sdata, sdata); | 956 | rcu_assign_pointer(local->sched_scan_sdata, sdata); |
959 | goto out; | ||
960 | } | ||
961 | 957 | ||
962 | out_free: | 958 | out_free: |
963 | while (i > 0) | 959 | while (i > 0) |
964 | kfree(local->sched_scan_ies.ie[--i]); | 960 | kfree(sched_scan_ies.ie[--i]); |
965 | out: | 961 | out: |
966 | mutex_unlock(&local->mtx); | 962 | mutex_unlock(&local->mtx); |
967 | return ret; | 963 | return ret; |
@@ -970,7 +966,7 @@ out: | |||
970 | int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata) | 966 | int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata) |
971 | { | 967 | { |
972 | struct ieee80211_local *local = sdata->local; | 968 | struct ieee80211_local *local = sdata->local; |
973 | int ret = 0, i; | 969 | int ret = 0; |
974 | 970 | ||
975 | mutex_lock(&local->mtx); | 971 | mutex_lock(&local->mtx); |
976 | 972 | ||
@@ -979,12 +975,9 @@ int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata) | |||
979 | goto out; | 975 | goto out; |
980 | } | 976 | } |
981 | 977 | ||
982 | if (rcu_access_pointer(local->sched_scan_sdata)) { | 978 | if (rcu_access_pointer(local->sched_scan_sdata)) |
983 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) | ||
984 | kfree(local->sched_scan_ies.ie[i]); | ||
985 | |||
986 | drv_sched_scan_stop(local, sdata); | 979 | drv_sched_scan_stop(local, sdata); |
987 | } | 980 | |
988 | out: | 981 | out: |
989 | mutex_unlock(&local->mtx); | 982 | mutex_unlock(&local->mtx); |
990 | 983 | ||
@@ -1006,7 +999,6 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work) | |||
1006 | struct ieee80211_local *local = | 999 | struct ieee80211_local *local = |
1007 | container_of(work, struct ieee80211_local, | 1000 | container_of(work, struct ieee80211_local, |
1008 | sched_scan_stopped_work); | 1001 | sched_scan_stopped_work); |
1009 | int i; | ||
1010 | 1002 | ||
1011 | mutex_lock(&local->mtx); | 1003 | mutex_lock(&local->mtx); |
1012 | 1004 | ||
@@ -1015,9 +1007,6 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work) | |||
1015 | return; | 1007 | return; |
1016 | } | 1008 | } |
1017 | 1009 | ||
1018 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) | ||
1019 | kfree(local->sched_scan_ies.ie[i]); | ||
1020 | |||
1021 | rcu_assign_pointer(local->sched_scan_sdata, NULL); | 1010 | rcu_assign_pointer(local->sched_scan_sdata, NULL); |
1022 | 1011 | ||
1023 | mutex_unlock(&local->mtx); | 1012 | mutex_unlock(&local->mtx); |