Skip to content

Commit

Permalink
net: wifi: shell: free station certs memory during disconnect
Browse files Browse the repository at this point in the history
It will be have a relative high probability to get continuous memory
for the next enterprise conenction, if free station certs memory
during disconnect, thus sys_heap need less memory for big size
EAP-TLS server cert packet, otherwise more memory space needed.

Signed-off-by: Rex Chen <[email protected]>
  • Loading branch information
Rex-Chen-NXP authored and kartben committed Dec 25, 2024
1 parent 4ce0ff5 commit 8955d9f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions modules/hostap/src/supp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,18 @@ int hapd_process_enterprise_config(struct hostapd_iface *iface,
}
#endif

#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
static void wpas_remove_certs(struct wpa_supplicant *wpa_s)
{
wpa_config_remove_blob(wpa_s->conf, "ca_cert");
wpa_config_remove_blob(wpa_s->conf, "client_cert");
wpa_config_remove_blob(wpa_s->conf, "private_key");
wpa_config_remove_blob(wpa_s->conf, "ca_cert2");
wpa_config_remove_blob(wpa_s->conf, "client_cert2");
wpa_config_remove_blob(wpa_s->conf, "private_key2");
}
#endif

static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s,
struct wifi_connect_req_params *params,
bool mode_ap)
Expand All @@ -844,6 +856,8 @@ static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s,
char phase1[128] = {0};
char *phase2 = NULL;
unsigned int index;

wpas_remove_certs(wpa_s);
#endif

if (!wpa_cli_cmd_v("remove_network all")) {
Expand Down Expand Up @@ -1365,6 +1379,10 @@ static int wpas_disconnect_network(const struct device *dev, int cur_mode)
wifi_mgmt_raise_disconnect_complete_event(iface, ret);
}

#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
wpas_remove_certs(wpa_s);
#endif

if (!wpa_cli_cmd_v("remove_network all")) {
wpa_printf(MSG_ERROR, "Failed to remove all networks");
}
Expand Down

0 comments on commit 8955d9f

Please sign in to comment.