diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 9e87b8096..a13a135e0 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -570,11 +570,7 @@ static void handle_auth(struct hostapd_data *hapd, HOSTAPD_LEVEL_INFO, "VLAN ID %d", sta->vlan_id); } - while (sta->psk) { - struct hostapd_sta_wpa_psk_short *prev = sta->psk; - sta->psk = sta->psk->next; - os_free(prev); - } + hostapd_free_psk_list(sta->psk); if (hapd->conf->wpa_psk_radius != PSK_RADIUS_IGNORED) { sta->psk = psk; psk = NULL; @@ -655,11 +651,7 @@ static void handle_auth(struct hostapd_data *hapd, fail: os_free(identity); os_free(radius_cui); - while (psk) { - struct hostapd_sta_wpa_psk_short *prev = psk; - psk = psk->next; - os_free(prev); - } + hostapd_free_psk_list(psk); send_auth_reply(hapd, mgmt->sa, mgmt->bssid, auth_alg, auth_transaction + 1, resp, resp_ies, resp_ies_len); diff --git a/src/ap/ieee802_11_auth.c b/src/ap/ieee802_11_auth.c index acdd527e1..c311e5594 100644 --- a/src/ap/ieee802_11_auth.c +++ b/src/ap/ieee802_11_auth.c @@ -55,14 +55,9 @@ struct hostapd_acl_query_data { #ifndef CONFIG_NO_RADIUS static void hostapd_acl_cache_free_entry(struct hostapd_cached_radius_acl *e) { - struct hostapd_sta_wpa_psk_short *psk = e->psk; os_free(e->identity); os_free(e->radius_cui); - while (psk) { - struct hostapd_sta_wpa_psk_short *prev = psk; - psk = psk->next; - os_free(prev); - } + hostapd_free_psk_list(e->psk); os_free(e); } @@ -636,3 +631,13 @@ void hostapd_acl_deinit(struct hostapd_data *hapd) hostapd_acl_query_free(prev); } } + + +void hostapd_free_psk_list(struct hostapd_sta_wpa_psk_short *psk) +{ + while (psk) { + struct hostapd_sta_wpa_psk_short *prev = psk; + psk = psk->next; + os_free(prev); + } +} diff --git a/src/ap/ieee802_11_auth.h b/src/ap/ieee802_11_auth.h index 7bbc09ae4..2bc1065a2 100644 --- a/src/ap/ieee802_11_auth.h +++ b/src/ap/ieee802_11_auth.h @@ -23,5 +23,6 @@ int hostapd_allowed_address(struct hostapd_data *hapd, const u8 *addr, char **identity, char **radius_cui); int hostapd_acl_init(struct hostapd_data *hapd); void hostapd_acl_deinit(struct hostapd_data *hapd); +void hostapd_free_psk_list(struct hostapd_sta_wpa_psk_short *psk); #endif /* IEEE802_11_AUTH_H */ diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c index ef1aab891..6bc43d2d5 100644 --- a/src/ap/sta_info.c +++ b/src/ap/sta_info.c @@ -20,6 +20,7 @@ #include "accounting.h" #include "ieee802_1x.h" #include "ieee802_11.h" +#include "ieee802_11_auth.h" #include "wpa_auth.h" #include "preauth_auth.h" #include "ap_config.h" @@ -235,11 +236,7 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta) wpabuf_free(sta->hs20_ie); os_free(sta->ht_capabilities); - while (sta->psk) { - struct hostapd_sta_wpa_psk_short *prev = sta->psk; - sta->psk = sta->psk->next; - os_free(prev); - } + hostapd_free_psk_list(sta->psk); os_free(sta->identity); os_free(sta->radius_cui);