fix(wpa_supplicant): Fix location of clearing up dpp global variables

- Fix location of cleaing up dpp global variables to ensure that there are
  no concurrency issues.
This commit is contained in:
jgujarathi 2023-11-21 12:12:32 +05:30
parent 8f928f77e8
commit 45caba87f1

View File

@ -18,7 +18,6 @@ static void *s_dpp_evt_queue = NULL;
static void *s_dpp_api_lock = NULL; static void *s_dpp_api_lock = NULL;
static bool s_dpp_listen_in_progress; static bool s_dpp_listen_in_progress;
static int s_dpp_auth_retries;
static struct esp_dpp_context_t s_dpp_ctx; static struct esp_dpp_context_t s_dpp_ctx;
static wifi_action_rx_cb_t s_action_rx_cb = esp_supp_rx_action; static wifi_action_rx_cb_t s_action_rx_cb = esp_supp_rx_action;
@ -361,6 +360,21 @@ static void esp_dpp_task(void *pvParameters )
switch (evt->id) { switch (evt->id) {
case SIG_DPP_DEL_TASK: case SIG_DPP_DEL_TASK:
struct dpp_bootstrap_params_t *params = &s_dpp_ctx.bootstrap_params;
if (params->info) {
os_free(params->info);
params->info = NULL;
}
if (params->key) {
os_free(params->key);
params->key = NULL;
}
if (s_dpp_ctx.dpp_global) {
dpp_global_deinit(s_dpp_ctx.dpp_global);
s_dpp_ctx.dpp_global = NULL;
}
if (s_dpp_ctx.dpp_auth) { if (s_dpp_ctx.dpp_auth) {
dpp_auth_deinit(s_dpp_ctx.dpp_auth); dpp_auth_deinit(s_dpp_ctx.dpp_auth);
s_dpp_ctx.dpp_auth = NULL; s_dpp_ctx.dpp_auth = NULL;
@ -713,25 +727,14 @@ esp_err_t esp_supp_dpp_init(esp_supp_dpp_event_cb_t cb)
void esp_supp_dpp_deinit(void) void esp_supp_dpp_deinit(void)
{ {
struct dpp_bootstrap_params_t *params = &s_dpp_ctx.bootstrap_params;
if (params->info) {
os_free(params->info);
params->info = NULL;
}
if (params->key) {
os_free(params->key);
params->key = NULL;
}
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_ACTION_TX_STATUS, esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_ACTION_TX_STATUS,
&offchan_event_handler); &offchan_event_handler);
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_ROC_DONE, esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_ROC_DONE,
&offchan_event_handler); &offchan_event_handler);
s_dpp_auth_retries = 0;
if (s_dpp_ctx.dpp_global) { if (s_dpp_ctx.dpp_global) {
dpp_global_deinit(s_dpp_ctx.dpp_global); if (esp_dpp_post_evt(SIG_DPP_DEL_TASK, 0)) {
s_dpp_ctx.dpp_global = NULL; wpa_printf(MSG_ERROR, "DPP Deinit Failed");
esp_dpp_post_evt(SIG_DPP_DEL_TASK, 0); }
} }
} }
#endif #endif