Skip to content

Commit 8955d9f

Browse files
Rex-Chen-NXPkartben
authored andcommitted
net: wifi: shell: free station certs memory during disconnect
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]>
1 parent 4ce0ff5 commit 8955d9f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

modules/hostap/src/supp_api.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,18 @@ int hapd_process_enterprise_config(struct hostapd_iface *iface,
826826
}
827827
#endif
828828

829+
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
830+
static void wpas_remove_certs(struct wpa_supplicant *wpa_s)
831+
{
832+
wpa_config_remove_blob(wpa_s->conf, "ca_cert");
833+
wpa_config_remove_blob(wpa_s->conf, "client_cert");
834+
wpa_config_remove_blob(wpa_s->conf, "private_key");
835+
wpa_config_remove_blob(wpa_s->conf, "ca_cert2");
836+
wpa_config_remove_blob(wpa_s->conf, "client_cert2");
837+
wpa_config_remove_blob(wpa_s->conf, "private_key2");
838+
}
839+
#endif
840+
829841
static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s,
830842
struct wifi_connect_req_params *params,
831843
bool mode_ap)
@@ -844,6 +856,8 @@ static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s,
844856
char phase1[128] = {0};
845857
char *phase2 = NULL;
846858
unsigned int index;
859+
860+
wpas_remove_certs(wpa_s);
847861
#endif
848862

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

1382+
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
1383+
wpas_remove_certs(wpa_s);
1384+
#endif
1385+
13681386
if (!wpa_cli_cmd_v("remove_network all")) {
13691387
wpa_printf(MSG_ERROR, "Failed to remove all networks");
13701388
}

0 commit comments

Comments
 (0)