]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use a shared function for freeing PSK list
authorJouni Malinen <j@w1.fi>
Sun, 25 Nov 2012 16:01:55 +0000 (18:01 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 25 Nov 2012 16:01:55 +0000 (18:01 +0200)
There is no need to duplicate this code in multiple locations.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/ap/ieee802_11.c
src/ap/ieee802_11_auth.c
src/ap/ieee802_11_auth.h
src/ap/sta_info.c

index 9e87b8096a3d7479085ebf852a28380e5172f7bb..a13a135e0f2639f1349fd299dc9af72093062896 100644 (file)
@@ -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);
index acdd527e1adcb6d3379d8b326a64a648dc75af03..c311e55949e3db484d53ad27ab19091336f6acb1 100644 (file)
@@ -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);
+       }
+}
index 7bbc09ae4e339960eb53495a2668cdadeb12b1cb..2bc1065a226c94a4cb9598f25890a6871d955fb6 100644 (file)
@@ -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 */
index ef1aab89182925fc3a36efec3944737e24335079..6bc43d2d5e95fc4763557cbab880a11521f1ce72 100644 (file)
@@ -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);