Skip to content

Commit

Permalink
mac80211: Move ieee80211_mgd_auth() EBUSY check to be before allocation
Browse files Browse the repository at this point in the history
This makes it easier to conditionally replace full allocation of
auth_data to use reallocation for the case of continuing SAE
authentication. Furthermore, there was not really any point in having
this check done so late in the function after having already completed
number of steps that cannot be used anyway in the error case.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Jouni Malinen authored and Johannes Berg committed Oct 11, 2018
1 parent fc107a9 commit 8d7432a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions net/mac80211/mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -4922,6 +4922,10 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
return -EOPNOTSUPP;
}

if ((ifmgd->auth_data && !ifmgd->auth_data->done) ||
ifmgd->assoc_data)
return -EBUSY;

auth_data = kzalloc(sizeof(*auth_data) + req->auth_data_len +
req->ie_len, GFP_KERNEL);
if (!auth_data)
Expand Down Expand Up @@ -4957,12 +4961,6 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,

/* try to authenticate/probe */

if ((ifmgd->auth_data && !ifmgd->auth_data->done) ||
ifmgd->assoc_data) {
err = -EBUSY;
goto err_free;
}

if (ifmgd->auth_data)
ieee80211_destroy_auth_data(sdata, false);

Expand Down Expand Up @@ -5007,7 +5005,6 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
mutex_lock(&sdata->local->mtx);
ieee80211_vif_release_channel(sdata);
mutex_unlock(&sdata->local->mtx);
err_free:
kfree(auth_data);
return err;
}
Expand Down

0 comments on commit 8d7432a

Please sign in to comment.