diff --git a/src/adhoc.c b/src/adhoc.c index fb671758..cabd507a 100644 --- a/src/adhoc.c +++ b/src/adhoc.c @@ -74,12 +74,14 @@ static void adhoc_sta_free(void *data) if (sta->sm) eapol_sm_free(sta->sm); - handshake_state_free(sta->hs_sta); + if (sta->hs_sta) + handshake_state_free(sta->hs_sta); if (sta->sm_a) eapol_sm_free(sta->sm_a); - handshake_state_free(sta->hs_auth); + if (sta->hs_auth) + handshake_state_free(sta->hs_auth); end: l_free(sta); diff --git a/src/ap.c b/src/ap.c index 4d73b8e4..1af67201 100644 --- a/src/ap.c +++ b/src/ap.c @@ -93,8 +93,11 @@ static void ap_sta_free(void *data) if (sta->assoc_resp_cmd_id) l_genl_family_cancel(nl80211, sta->assoc_resp_cmd_id); - eapol_sm_free(sta->sm); - handshake_state_free(sta->hs); + if (sta->sm) + eapol_sm_free(sta->sm); + + if (sta->hs) + handshake_state_free(sta->hs); l_free(sta); }