mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
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:
parent
34dd886c19
commit
0c2bef4621
@ -1566,7 +1566,7 @@ static int ieee80211_change_station(struct wiphy *wiphy,
|
||||
|
||||
if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ static void ieee80211_unassign_vif_chanctx(struct ieee80211_sub_if_data *sdata,
|
||||
lockdep_assert_held(&local->chanctx_mtx);
|
||||
|
||||
ctx->refcount--;
|
||||
rcu_assign_pointer(sdata->vif.chanctx_conf, NULL);
|
||||
RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL);
|
||||
|
||||
sdata->vif.bss_conf.idle = true;
|
||||
|
||||
|
@ -128,7 +128,7 @@ static ssize_t sta_tx_latency_stat_write(struct file *file,
|
||||
if (!strcmp(buf, TX_LATENCY_DISABLED)) {
|
||||
if (!tx_latency)
|
||||
goto unlock;
|
||||
rcu_assign_pointer(local->tx_latency, NULL);
|
||||
RCU_INIT_POINTER(local->tx_latency, NULL);
|
||||
synchronize_rcu();
|
||||
kfree(tx_latency);
|
||||
goto unlock;
|
||||
|
@ -253,7 +253,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
|
||||
|
||||
presp = rcu_dereference_protected(ifibss->presp,
|
||||
lockdep_is_held(&sdata->wdev.mtx));
|
||||
rcu_assign_pointer(ifibss->presp, NULL);
|
||||
RCU_INIT_POINTER(ifibss->presp, NULL);
|
||||
if (presp)
|
||||
kfree_rcu(presp, rcu_head);
|
||||
|
||||
|
@ -423,7 +423,7 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local)
|
||||
mutex_unlock(&local->mtx);
|
||||
if (ret) {
|
||||
mutex_lock(&local->iflist_mtx);
|
||||
rcu_assign_pointer(local->monitor_sdata, NULL);
|
||||
RCU_INIT_POINTER(local->monitor_sdata, NULL);
|
||||
mutex_unlock(&local->iflist_mtx);
|
||||
synchronize_net();
|
||||
drv_remove_interface(local, sdata);
|
||||
@ -452,7 +452,7 @@ void ieee80211_del_virtual_monitor(struct ieee80211_local *local)
|
||||
return;
|
||||
}
|
||||
|
||||
rcu_assign_pointer(local->monitor_sdata, NULL);
|
||||
RCU_INIT_POINTER(local->monitor_sdata, NULL);
|
||||
mutex_unlock(&local->iflist_mtx);
|
||||
|
||||
synchronize_net();
|
||||
@ -876,7 +876,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
|
||||
switch (sdata->vif.type) {
|
||||
case NL80211_IFTYPE_AP_VLAN:
|
||||
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 */
|
||||
break;
|
||||
case NL80211_IFTYPE_MONITOR:
|
||||
@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
|
||||
break;
|
||||
case NL80211_IFTYPE_P2P_DEVICE:
|
||||
/* relies on synchronize_rcu() below */
|
||||
rcu_assign_pointer(local->p2p_sdata, NULL);
|
||||
RCU_INIT_POINTER(local->p2p_sdata, NULL);
|
||||
/* fall through */
|
||||
default:
|
||||
cancel_work_sync(&sdata->work);
|
||||
|
@ -829,7 +829,7 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
|
||||
ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
|
||||
bcn = rcu_dereference_protected(ifmsh->beacon,
|
||||
lockdep_is_held(&sdata->wdev.mtx));
|
||||
rcu_assign_pointer(ifmsh->beacon, NULL);
|
||||
RCU_INIT_POINTER(ifmsh->beacon, NULL);
|
||||
kfree_rcu(bcn, rcu_head);
|
||||
|
||||
/* 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 */
|
||||
tmp_csa_settings = rcu_dereference(ifmsh->csa);
|
||||
rcu_assign_pointer(ifmsh->csa, NULL);
|
||||
RCU_INIT_POINTER(ifmsh->csa, NULL);
|
||||
if (tmp_csa_settings)
|
||||
kfree_rcu(tmp_csa_settings, rcu_head);
|
||||
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);
|
||||
if (ret) {
|
||||
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);
|
||||
return ret;
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
|
||||
if (local->scan_req != local->int_scan_req)
|
||||
cfg80211_scan_done(local->scan_req, aborted);
|
||||
local->scan_req = NULL;
|
||||
rcu_assign_pointer(local->scan_sdata, NULL);
|
||||
RCU_INIT_POINTER(local->scan_sdata, NULL);
|
||||
|
||||
local->scanning = 0;
|
||||
local->scan_chandef.chan = NULL;
|
||||
@ -559,7 +559,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
|
||||
ieee80211_recalc_idle(local);
|
||||
|
||||
local->scan_req = NULL;
|
||||
rcu_assign_pointer(local->scan_sdata, NULL);
|
||||
RCU_INIT_POINTER(local->scan_sdata, NULL);
|
||||
}
|
||||
|
||||
return rc;
|
||||
@ -773,7 +773,7 @@ void ieee80211_scan_work(struct work_struct *work)
|
||||
int rc;
|
||||
|
||||
local->scan_req = NULL;
|
||||
rcu_assign_pointer(local->scan_sdata, NULL);
|
||||
RCU_INIT_POINTER(local->scan_sdata, NULL);
|
||||
|
||||
rc = __ieee80211_start_scan(sdata, req);
|
||||
if (rc) {
|
||||
@ -1014,7 +1014,7 @@ out_free:
|
||||
|
||||
if (ret) {
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@ -1089,7 +1089,7 @@ void ieee80211_sched_scan_stopped_work(struct work_struct *work)
|
||||
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. */
|
||||
local->sched_scan_req = NULL;
|
||||
|
@ -1546,7 +1546,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
|
||||
WARN_ON(local->resuming);
|
||||
res = drv_add_interface(local, sdata);
|
||||
if (WARN_ON(res)) {
|
||||
rcu_assign_pointer(local->monitor_sdata, NULL);
|
||||
RCU_INIT_POINTER(local->monitor_sdata, NULL);
|
||||
synchronize_net();
|
||||
kfree(sdata);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user