diff options
author | Monam Agarwal <monamagarwal123@gmail.com> | 2014-03-23 15:21:43 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2014-04-09 04:55:30 -0400 |
commit | 0c2bef4621c5feb5bda9068c9964b2e9acf57017 (patch) | |
tree | 0c57534e45d0d072873dcab9b5fddf54b3fef6a7 /net | |
parent | 34dd886c19547ea138634b98a615ccd1fe42cd20 (diff) |
mac80211: use RCU_INIT_POINTER
rcu_assign_pointer() ensures that the initialization of a structure is
carried out before storing a pointer to that structure. However, in the
case that NULL is assigned there's no structure to initialize so using
RCU_INIT_POINTER instead is safe and more efficient.
Signed-off-by: Monam Agarwal <monamagarwal123@gmail.com>
[squash eight tiny patches, rewrite commit log]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/mac80211/cfg.c | 2 | ||||
-rw-r--r-- | net/mac80211/chan.c | 2 | ||||
-rw-r--r-- | net/mac80211/debugfs.c | 2 | ||||
-rw-r--r-- | net/mac80211/ibss.c | 2 | ||||
-rw-r--r-- | net/mac80211/iface.c | 8 | ||||
-rw-r--r-- | net/mac80211/mesh.c | 6 | ||||
-rw-r--r-- | net/mac80211/scan.c | 10 | ||||
-rw-r--r-- | net/mac80211/util.c | 2 |
8 files changed, 17 insertions, 17 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index aaa59d719592..906bc3b05aae 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -1566,7 +1566,7 @@ static int ieee80211_change_station(struct wiphy *wiphy, | |||
1566 | 1566 | ||
1567 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && | 1567 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && |
1568 | sta->sdata->u.vlan.sta) { | 1568 | sta->sdata->u.vlan.sta) { |
1569 | rcu_assign_pointer(sta->sdata->u.vlan.sta, NULL); | 1569 | RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL); |
1570 | prev_4addr = true; | 1570 | prev_4addr = true; |
1571 | } | 1571 | } |
1572 | 1572 | ||
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index bd1fd8ea5105..b297bd3043a8 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c | |||
@@ -392,7 +392,7 @@ static void ieee80211_unassign_vif_chanctx(struct ieee80211_sub_if_data *sdata, | |||
392 | lockdep_assert_held(&local->chanctx_mtx); | 392 | lockdep_assert_held(&local->chanctx_mtx); |
393 | 393 | ||
394 | ctx->refcount--; | 394 | ctx->refcount--; |
395 | rcu_assign_pointer(sdata->vif.chanctx_conf, NULL); | 395 | RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL); |
396 | 396 | ||
397 | sdata->vif.bss_conf.idle = true; | 397 | sdata->vif.bss_conf.idle = true; |
398 | 398 | ||
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index fa16e54980a1..0e963bc1ceac 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c | |||
@@ -128,7 +128,7 @@ static ssize_t sta_tx_latency_stat_write(struct file *file, | |||
128 | if (!strcmp(buf, TX_LATENCY_DISABLED)) { | 128 | if (!strcmp(buf, TX_LATENCY_DISABLED)) { |
129 | if (!tx_latency) | 129 | if (!tx_latency) |
130 | goto unlock; | 130 | goto unlock; |
131 | rcu_assign_pointer(local->tx_latency, NULL); | 131 | RCU_INIT_POINTER(local->tx_latency, NULL); |
132 | synchronize_rcu(); | 132 | synchronize_rcu(); |
133 | kfree(tx_latency); | 133 | kfree(tx_latency); |
134 | goto unlock; | 134 | goto unlock; |
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 06d28787945b..35e4f94d7ba1 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c | |||
@@ -253,7 +253,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
253 | 253 | ||
254 | presp = rcu_dereference_protected(ifibss->presp, | 254 | presp = rcu_dereference_protected(ifibss->presp, |
255 | lockdep_is_held(&sdata->wdev.mtx)); | 255 | lockdep_is_held(&sdata->wdev.mtx)); |
256 | rcu_assign_pointer(ifibss->presp, NULL); | 256 | RCU_INIT_POINTER(ifibss->presp, NULL); |
257 | if (presp) | 257 | if (presp) |
258 | kfree_rcu(presp, rcu_head); | 258 | kfree_rcu(presp, rcu_head); |
259 | 259 | ||
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index b8d331e7d883..4826c8f5d0b2 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
@@ -423,7 +423,7 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local) | |||
423 | mutex_unlock(&local->mtx); | 423 | mutex_unlock(&local->mtx); |
424 | if (ret) { | 424 | if (ret) { |
425 | mutex_lock(&local->iflist_mtx); | 425 | mutex_lock(&local->iflist_mtx); |
426 | rcu_assign_pointer(local->monitor_sdata, NULL); | 426 | RCU_INIT_POINTER(local->monitor_sdata, NULL); |
427 | mutex_unlock(&local->iflist_mtx); | 427 | mutex_unlock(&local->iflist_mtx); |
428 | synchronize_net(); | 428 | synchronize_net(); |
429 | drv_remove_interface(local, sdata); | 429 | drv_remove_interface(local, sdata); |
@@ -452,7 +452,7 @@ void ieee80211_del_virtual_monitor(struct ieee80211_local *local) | |||
452 | return; | 452 | return; |
453 | } | 453 | } |
454 | 454 | ||
455 | rcu_assign_pointer(local->monitor_sdata, NULL); | 455 | RCU_INIT_POINTER(local->monitor_sdata, NULL); |
456 | mutex_unlock(&local->iflist_mtx); | 456 | mutex_unlock(&local->iflist_mtx); |
457 | 457 | ||
458 | synchronize_net(); | 458 | synchronize_net(); |
@@ -876,7 +876,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
876 | switch (sdata->vif.type) { | 876 | switch (sdata->vif.type) { |
877 | case NL80211_IFTYPE_AP_VLAN: | 877 | case NL80211_IFTYPE_AP_VLAN: |
878 | list_del(&sdata->u.vlan.list); | 878 | list_del(&sdata->u.vlan.list); |
879 | rcu_assign_pointer(sdata->vif.chanctx_conf, NULL); | 879 | RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL); |
880 | /* no need to tell driver */ | 880 | /* no need to tell driver */ |
881 | break; | 881 | break; |
882 | case NL80211_IFTYPE_MONITOR: | 882 | case NL80211_IFTYPE_MONITOR: |
@@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
895 | break; | 895 | break; |
896 | case NL80211_IFTYPE_P2P_DEVICE: | 896 | case NL80211_IFTYPE_P2P_DEVICE: |
897 | /* relies on synchronize_rcu() below */ | 897 | /* relies on synchronize_rcu() below */ |
898 | rcu_assign_pointer(local->p2p_sdata, NULL); | 898 | RCU_INIT_POINTER(local->p2p_sdata, NULL); |
899 | /* fall through */ | 899 | /* fall through */ |
900 | default: | 900 | default: |
901 | cancel_work_sync(&sdata->work); | 901 | cancel_work_sync(&sdata->work); |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index f70e9cd10552..387f61c4557d 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -829,7 +829,7 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata) | |||
829 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); | 829 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); |
830 | bcn = rcu_dereference_protected(ifmsh->beacon, | 830 | bcn = rcu_dereference_protected(ifmsh->beacon, |
831 | lockdep_is_held(&sdata->wdev.mtx)); | 831 | lockdep_is_held(&sdata->wdev.mtx)); |
832 | rcu_assign_pointer(ifmsh->beacon, NULL); | 832 | RCU_INIT_POINTER(ifmsh->beacon, NULL); |
833 | kfree_rcu(bcn, rcu_head); | 833 | kfree_rcu(bcn, rcu_head); |
834 | 834 | ||
835 | /* flush STAs and mpaths on this iface */ | 835 | /* flush STAs and mpaths on this iface */ |
@@ -1068,7 +1068,7 @@ int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata) | |||
1068 | 1068 | ||
1069 | /* Remove the CSA and MCSP elements from the beacon */ | 1069 | /* Remove the CSA and MCSP elements from the beacon */ |
1070 | tmp_csa_settings = rcu_dereference(ifmsh->csa); | 1070 | tmp_csa_settings = rcu_dereference(ifmsh->csa); |
1071 | rcu_assign_pointer(ifmsh->csa, NULL); | 1071 | RCU_INIT_POINTER(ifmsh->csa, NULL); |
1072 | if (tmp_csa_settings) | 1072 | if (tmp_csa_settings) |
1073 | kfree_rcu(tmp_csa_settings, rcu_head); | 1073 | kfree_rcu(tmp_csa_settings, rcu_head); |
1074 | ret = ieee80211_mesh_rebuild_beacon(sdata); | 1074 | ret = ieee80211_mesh_rebuild_beacon(sdata); |
@@ -1102,7 +1102,7 @@ int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata, | |||
1102 | ret = ieee80211_mesh_rebuild_beacon(sdata); | 1102 | ret = ieee80211_mesh_rebuild_beacon(sdata); |
1103 | if (ret) { | 1103 | if (ret) { |
1104 | tmp_csa_settings = rcu_dereference(ifmsh->csa); | 1104 | tmp_csa_settings = rcu_dereference(ifmsh->csa); |
1105 | rcu_assign_pointer(ifmsh->csa, NULL); | 1105 | RCU_INIT_POINTER(ifmsh->csa, NULL); |
1106 | kfree_rcu(tmp_csa_settings, rcu_head); | 1106 | kfree_rcu(tmp_csa_settings, rcu_head); |
1107 | return ret; | 1107 | return ret; |
1108 | } | 1108 | } |
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 3ce7f2c8539a..28185c8dc19a 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c | |||
@@ -309,7 +309,7 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) | |||
309 | if (local->scan_req != local->int_scan_req) | 309 | if (local->scan_req != local->int_scan_req) |
310 | cfg80211_scan_done(local->scan_req, aborted); | 310 | cfg80211_scan_done(local->scan_req, aborted); |
311 | local->scan_req = NULL; | 311 | local->scan_req = NULL; |
312 | rcu_assign_pointer(local->scan_sdata, NULL); | 312 | RCU_INIT_POINTER(local->scan_sdata, NULL); |
313 | 313 | ||
314 | local->scanning = 0; | 314 | local->scanning = 0; |
315 | local->scan_chandef.chan = NULL; | 315 | local->scan_chandef.chan = NULL; |
@@ -559,7 +559,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | |||
559 | ieee80211_recalc_idle(local); | 559 | ieee80211_recalc_idle(local); |
560 | 560 | ||
561 | local->scan_req = NULL; | 561 | local->scan_req = NULL; |
562 | rcu_assign_pointer(local->scan_sdata, NULL); | 562 | RCU_INIT_POINTER(local->scan_sdata, NULL); |
563 | } | 563 | } |
564 | 564 | ||
565 | return rc; | 565 | return rc; |
@@ -773,7 +773,7 @@ void ieee80211_scan_work(struct work_struct *work) | |||
773 | int rc; | 773 | int rc; |
774 | 774 | ||
775 | local->scan_req = NULL; | 775 | local->scan_req = NULL; |
776 | rcu_assign_pointer(local->scan_sdata, NULL); | 776 | RCU_INIT_POINTER(local->scan_sdata, NULL); |
777 | 777 | ||
778 | rc = __ieee80211_start_scan(sdata, req); | 778 | rc = __ieee80211_start_scan(sdata, req); |
779 | if (rc) { | 779 | if (rc) { |
@@ -1014,7 +1014,7 @@ out_free: | |||
1014 | 1014 | ||
1015 | if (ret) { | 1015 | if (ret) { |
1016 | /* Clean in case of failure after HW restart or upon resume. */ | 1016 | /* Clean in case of failure after HW restart or upon resume. */ |
1017 | rcu_assign_pointer(local->sched_scan_sdata, NULL); | 1017 | RCU_INIT_POINTER(local->sched_scan_sdata, NULL); |
1018 | local->sched_scan_req = NULL; | 1018 | local->sched_scan_req = NULL; |
1019 | } | 1019 | } |
1020 | 1020 | ||
@@ -1089,7 +1089,7 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work) | |||
1089 | return; | 1089 | return; |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | rcu_assign_pointer(local->sched_scan_sdata, NULL); | 1092 | RCU_INIT_POINTER(local->sched_scan_sdata, NULL); |
1093 | 1093 | ||
1094 | /* If sched scan was aborted by the driver. */ | 1094 | /* If sched scan was aborted by the driver. */ |
1095 | local->sched_scan_req = NULL; | 1095 | local->sched_scan_req = NULL; |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 5cf62ec74c14..73af7398850b 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -1546,7 +1546,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1546 | WARN_ON(local->resuming); | 1546 | WARN_ON(local->resuming); |
1547 | res = drv_add_interface(local, sdata); | 1547 | res = drv_add_interface(local, sdata); |
1548 | if (WARN_ON(res)) { | 1548 | if (WARN_ON(res)) { |
1549 | rcu_assign_pointer(local->monitor_sdata, NULL); | 1549 | RCU_INIT_POINTER(local->monitor_sdata, NULL); |
1550 | synchronize_net(); | 1550 | synchronize_net(); |
1551 | kfree(sdata); | 1551 | kfree(sdata); |
1552 | } | 1552 | } |