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>
This commit is contained in:
Monam Agarwal 2014-03-24 00:51:43 +05:30 committed by Johannes Berg
parent 34dd886c19
commit 0c2bef4621
8 changed files with 17 additions and 17 deletions

View File

@ -1566,7 +1566,7 @@ static int ieee80211_change_station(struct wiphy *wiphy,
if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
sta->sdata->u.vlan.sta) { sta->sdata->u.vlan.sta) {
rcu_assign_pointer(sta->sdata->u.vlan.sta, NULL); RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
prev_4addr = true; prev_4addr = true;
} }

View File

@ -392,7 +392,7 @@ static void ieee80211_unassign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_held(&local->chanctx_mtx);
ctx->refcount--; ctx->refcount--;
rcu_assign_pointer(sdata->vif.chanctx_conf, NULL); RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL);
sdata->vif.bss_conf.idle = true; sdata->vif.bss_conf.idle = true;

View File

@ -128,7 +128,7 @@ static ssize_t sta_tx_latency_stat_write(struct file *file,
if (!strcmp(buf, TX_LATENCY_DISABLED)) { if (!strcmp(buf, TX_LATENCY_DISABLED)) {
if (!tx_latency) if (!tx_latency)
goto unlock; goto unlock;
rcu_assign_pointer(local->tx_latency, NULL); RCU_INIT_POINTER(local->tx_latency, NULL);
synchronize_rcu(); synchronize_rcu();
kfree(tx_latency); kfree(tx_latency);
goto unlock; goto unlock;

View File

@ -253,7 +253,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
presp = rcu_dereference_protected(ifibss->presp, presp = rcu_dereference_protected(ifibss->presp,
lockdep_is_held(&sdata->wdev.mtx)); lockdep_is_held(&sdata->wdev.mtx));
rcu_assign_pointer(ifibss->presp, NULL); RCU_INIT_POINTER(ifibss->presp, NULL);
if (presp) if (presp)
kfree_rcu(presp, rcu_head); kfree_rcu(presp, rcu_head);

View File

@ -423,7 +423,7 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local)
mutex_unlock(&local->mtx); mutex_unlock(&local->mtx);
if (ret) { if (ret) {
mutex_lock(&local->iflist_mtx); mutex_lock(&local->iflist_mtx);
rcu_assign_pointer(local->monitor_sdata, NULL); RCU_INIT_POINTER(local->monitor_sdata, NULL);
mutex_unlock(&local->iflist_mtx); mutex_unlock(&local->iflist_mtx);
synchronize_net(); synchronize_net();
drv_remove_interface(local, sdata); drv_remove_interface(local, sdata);
@ -452,7 +452,7 @@ void ieee80211_del_virtual_monitor(struct ieee80211_local *local)
return; return;
} }
rcu_assign_pointer(local->monitor_sdata, NULL); RCU_INIT_POINTER(local->monitor_sdata, NULL);
mutex_unlock(&local->iflist_mtx); mutex_unlock(&local->iflist_mtx);
synchronize_net(); synchronize_net();
@ -876,7 +876,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
switch (sdata->vif.type) { switch (sdata->vif.type) {
case NL80211_IFTYPE_AP_VLAN: case NL80211_IFTYPE_AP_VLAN:
list_del(&sdata->u.vlan.list); list_del(&sdata->u.vlan.list);
rcu_assign_pointer(sdata->vif.chanctx_conf, NULL); RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL);
/* no need to tell driver */ /* no need to tell driver */
break; break;
case NL80211_IFTYPE_MONITOR: case NL80211_IFTYPE_MONITOR:
@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
break; break;
case NL80211_IFTYPE_P2P_DEVICE: case NL80211_IFTYPE_P2P_DEVICE:
/* relies on synchronize_rcu() below */ /* relies on synchronize_rcu() below */
rcu_assign_pointer(local->p2p_sdata, NULL); RCU_INIT_POINTER(local->p2p_sdata, NULL);
/* fall through */ /* fall through */
default: default:
cancel_work_sync(&sdata->work); cancel_work_sync(&sdata->work);

View File

@ -829,7 +829,7 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
bcn = rcu_dereference_protected(ifmsh->beacon, bcn = rcu_dereference_protected(ifmsh->beacon,
lockdep_is_held(&sdata->wdev.mtx)); lockdep_is_held(&sdata->wdev.mtx));
rcu_assign_pointer(ifmsh->beacon, NULL); RCU_INIT_POINTER(ifmsh->beacon, NULL);
kfree_rcu(bcn, rcu_head); kfree_rcu(bcn, rcu_head);
/* flush STAs and mpaths on this iface */ /* flush STAs and mpaths on this iface */
@ -1068,7 +1068,7 @@ int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata)
/* Remove the CSA and MCSP elements from the beacon */ /* Remove the CSA and MCSP elements from the beacon */
tmp_csa_settings = rcu_dereference(ifmsh->csa); tmp_csa_settings = rcu_dereference(ifmsh->csa);
rcu_assign_pointer(ifmsh->csa, NULL); RCU_INIT_POINTER(ifmsh->csa, NULL);
if (tmp_csa_settings) if (tmp_csa_settings)
kfree_rcu(tmp_csa_settings, rcu_head); kfree_rcu(tmp_csa_settings, rcu_head);
ret = ieee80211_mesh_rebuild_beacon(sdata); ret = ieee80211_mesh_rebuild_beacon(sdata);
@ -1102,7 +1102,7 @@ int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata,
ret = ieee80211_mesh_rebuild_beacon(sdata); ret = ieee80211_mesh_rebuild_beacon(sdata);
if (ret) { if (ret) {
tmp_csa_settings = rcu_dereference(ifmsh->csa); tmp_csa_settings = rcu_dereference(ifmsh->csa);
rcu_assign_pointer(ifmsh->csa, NULL); RCU_INIT_POINTER(ifmsh->csa, NULL);
kfree_rcu(tmp_csa_settings, rcu_head); kfree_rcu(tmp_csa_settings, rcu_head);
return ret; return ret;
} }

View File

@ -309,7 +309,7 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
if (local->scan_req != local->int_scan_req) if (local->scan_req != local->int_scan_req)
cfg80211_scan_done(local->scan_req, aborted); cfg80211_scan_done(local->scan_req, aborted);
local->scan_req = NULL; local->scan_req = NULL;
rcu_assign_pointer(local->scan_sdata, NULL); RCU_INIT_POINTER(local->scan_sdata, NULL);
local->scanning = 0; local->scanning = 0;
local->scan_chandef.chan = NULL; local->scan_chandef.chan = NULL;
@ -559,7 +559,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
ieee80211_recalc_idle(local); ieee80211_recalc_idle(local);
local->scan_req = NULL; local->scan_req = NULL;
rcu_assign_pointer(local->scan_sdata, NULL); RCU_INIT_POINTER(local->scan_sdata, NULL);
} }
return rc; return rc;
@ -773,7 +773,7 @@ void ieee80211_scan_work(struct work_struct *work)
int rc; int rc;
local->scan_req = NULL; local->scan_req = NULL;
rcu_assign_pointer(local->scan_sdata, NULL); RCU_INIT_POINTER(local->scan_sdata, NULL);
rc = __ieee80211_start_scan(sdata, req); rc = __ieee80211_start_scan(sdata, req);
if (rc) { if (rc) {
@ -1014,7 +1014,7 @@ out_free:
if (ret) { if (ret) {
/* Clean in case of failure after HW restart or upon resume. */ /* Clean in case of failure after HW restart or upon resume. */
rcu_assign_pointer(local->sched_scan_sdata, NULL); RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
local->sched_scan_req = NULL; local->sched_scan_req = NULL;
} }
@ -1089,7 +1089,7 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work)
return; return;
} }
rcu_assign_pointer(local->sched_scan_sdata, NULL); RCU_INIT_POINTER(local->sched_scan_sdata, NULL);
/* If sched scan was aborted by the driver. */ /* If sched scan was aborted by the driver. */
local->sched_scan_req = NULL; local->sched_scan_req = NULL;

View File

@ -1546,7 +1546,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
WARN_ON(local->resuming); WARN_ON(local->resuming);
res = drv_add_interface(local, sdata); res = drv_add_interface(local, sdata);
if (WARN_ON(res)) { if (WARN_ON(res)) {
rcu_assign_pointer(local->monitor_sdata, NULL); RCU_INIT_POINTER(local->monitor_sdata, NULL);
synchronize_net(); synchronize_net();
kfree(sdata); kfree(sdata);
} }