diff options
author | Koen Vandeputte <koen.vandeputte@ncentric.com> | 2016-12-14 17:28:59 +0100 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2016-12-15 10:56:52 +0100 |
commit | 0c2e384267b815fb784c415a90de7bdd78da0b66 (patch) | |
tree | f4468fed30a691043ed6f3422a325e6e2e1426b6 /net/mac80211/sta_info.c | |
parent | 445cd452fe5187e676eef02c917c9e5f837c749e (diff) | |
download | blackbird-op-linux-0c2e384267b815fb784c415a90de7bdd78da0b66.tar.gz blackbird-op-linux-0c2e384267b815fb784c415a90de7bdd78da0b66.zip |
mac80211: only alloc mem if a station doesn't exist yet
This speeds up the function in case a station already exists by avoiding
calling an expensive kzalloc just to free it again after the next check.
Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/sta_info.c')
-rw-r--r-- | net/mac80211/sta_info.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 4ab75a9d70c7..f5a24b742eda 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -513,23 +513,23 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU) { struct ieee80211_local *local = sta->local; struct ieee80211_sub_if_data *sdata = sta->sdata; - struct station_info *sinfo; + struct station_info *sinfo = NULL; int err = 0; lockdep_assert_held(&local->sta_mtx); - sinfo = kzalloc(sizeof(struct station_info), GFP_KERNEL); - if (!sinfo) { - err = -ENOMEM; - goto out_err; - } - /* check if STA exists already */ if (sta_info_get_bss(sdata, sta->sta.addr)) { err = -EEXIST; goto out_err; } + sinfo = kzalloc(sizeof(struct station_info), GFP_KERNEL); + if (!sinfo) { + err = -ENOMEM; + goto out_err; + } + local->num_sta++; local->sta_generation++; smp_mb(); |