forked from espressif/esp-idf
Merge branch 'bugfix/wps_disable_crash' into 'master'
Fix a crash in esp_wifi_wps_disable Closes WIFIBUG-252 and WIFIBUG-266 See merge request espressif/esp-idf!27233
This commit is contained in:
@@ -158,9 +158,11 @@ void wps_task(void *pvParameters )
|
||||
if (e->sig == SIG_WPS_ENABLE) {
|
||||
param->ret = wifi_wps_enable_internal((esp_wps_config_t *)(param->arg));
|
||||
} else if (e->sig == SIG_WPS_DISABLE) {
|
||||
DATA_MUTEX_TAKE();
|
||||
param->ret = wifi_wps_disable_internal();
|
||||
del_task = true;
|
||||
s_wps_task_hdl = NULL;
|
||||
DATA_MUTEX_GIVE();
|
||||
} else {
|
||||
param->ret = wifi_station_wps_start();
|
||||
}
|
||||
@@ -221,6 +223,12 @@ int wps_post(uint32_t sig, uint32_t par)
|
||||
wpa_printf(MSG_DEBUG, "wps post: sig=%" PRId32 " cnt=%d", sig, s_wps_sig_cnt[sig]);
|
||||
|
||||
DATA_MUTEX_TAKE();
|
||||
|
||||
if (!s_wps_task_hdl) {
|
||||
wpa_printf(MSG_DEBUG, "wps post: sig=%" PRId32 " failed as wps task has been deinited", sig);
|
||||
DATA_MUTEX_GIVE();
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (s_wps_sig_cnt[sig]) {
|
||||
wpa_printf(MSG_DEBUG, "wps post: sig=%" PRId32 " processing", sig);
|
||||
DATA_MUTEX_GIVE();
|
||||
@@ -1710,12 +1718,6 @@ int wps_task_deinit(void)
|
||||
wps_rxq_deinit();
|
||||
}
|
||||
|
||||
if (s_wps_data_lock) {
|
||||
os_semphr_delete(s_wps_data_lock);
|
||||
s_wps_data_lock = NULL;
|
||||
wpa_printf(MSG_DEBUG, "wps task deinit: free data lock");
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -1727,10 +1729,12 @@ int wps_task_init(void)
|
||||
*/
|
||||
wps_task_deinit();
|
||||
|
||||
s_wps_data_lock = os_recursive_mutex_create();
|
||||
if (!s_wps_data_lock) {
|
||||
wpa_printf(MSG_ERROR, "wps task init: failed to alloc data lock");
|
||||
goto _wps_no_mem;
|
||||
s_wps_data_lock = os_recursive_mutex_create();
|
||||
if (!s_wps_data_lock) {
|
||||
wpa_printf(MSG_ERROR, "wps task init: failed to alloc data lock");
|
||||
goto _wps_no_mem;
|
||||
}
|
||||
}
|
||||
|
||||
s_wps_api_sem = os_semphr_create(1, 0);
|
||||
@@ -1827,6 +1831,11 @@ int esp_wifi_wps_enable(const esp_wps_config_t *config)
|
||||
return ESP_ERR_WIFI_MODE;
|
||||
}
|
||||
|
||||
if (is_dpp_enabled()) {
|
||||
wpa_printf(MSG_ERROR, "wps enabled failed since DPP is initialized");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
API_MUTEX_TAKE();
|
||||
if (s_wps_enabled) {
|
||||
if (sm && os_memcmp(sm->identity, WSC_ID_REGISTRAR, sm->identity_len) == 0) {
|
||||
@@ -1879,10 +1888,6 @@ int wifi_wps_enable_internal(const esp_wps_config_t *config)
|
||||
wpa_printf(MSG_ERROR, "wps enable: invalid wps type");
|
||||
return ESP_ERR_WIFI_WPS_TYPE;
|
||||
}
|
||||
if (is_dpp_enabled()) {
|
||||
wpa_printf(MSG_ERROR, "wps enabled failed since DPP is initialized");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
wpa_printf(MSG_DEBUG, "Set factory information.");
|
||||
ret = wps_set_factory_info(config);
|
||||
if (ret != 0) {
|
||||
@@ -1908,6 +1913,11 @@ int wifi_wps_enable_internal(const esp_wps_config_t *config)
|
||||
int wifi_wps_disable_internal(void)
|
||||
{
|
||||
wps_set_status(WPS_STATUS_DISABLE);
|
||||
|
||||
/* Call wps_delete_timer to delete all WPS timer, no timer will call wps_post()
|
||||
* to post message to wps_task once this function returns.
|
||||
*/
|
||||
wps_delete_timer();
|
||||
wifi_station_wps_deinit();
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -1935,11 +1945,6 @@ int esp_wifi_wps_disable(void)
|
||||
wpa_printf(MSG_INFO, "wifi_wps_disable");
|
||||
wps_set_type(WPS_TYPE_DISABLE); /* Notify WiFi task */
|
||||
|
||||
/* Call wps_delete_timer to delete all WPS timer, no timer will call wps_post()
|
||||
* to post message to wps_task once this function returns.
|
||||
*/
|
||||
wps_delete_timer();
|
||||
|
||||
#ifdef USE_WPS_TASK
|
||||
ret = wps_post_block(SIG_WPS_DISABLE, 0);
|
||||
#else
|
||||
|
Reference in New Issue
Block a user