Skip to content

Commit

Permalink
mac80211: only alloc mem if a station doesn't exist yet
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Koen Vandeputte authored and Johannes Berg committed Dec 15, 2016
1 parent 445cd45 commit 0c2e384
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions net/mac80211/sta_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0c2e384

Please sign in to comment.