diff --git a/components/esp_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index 99bd15b62c..6473272cd3 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -102,6 +102,11 @@ esp_err_t esp_wifi_deinit(void) return ESP_ERR_WIFI_NOT_STOPPED; } + if (esp_wifi_internal_reg_rxcb(WIFI_IF_STA, NULL) != ESP_OK || + esp_wifi_internal_reg_rxcb(WIFI_IF_AP, NULL) != ESP_OK) { + ESP_LOGW(TAG, "Failed to unregister Rx callbacks"); + } + esp_supplicant_deinit(); err = esp_wifi_deinit_internal(); if (err != ESP_OK) { diff --git a/components/esp_wifi/src/wifi_netif.c b/components/esp_wifi/src/wifi_netif.c index 6f8454ed9a..134d993be4 100644 --- a/components/esp_wifi/src/wifi_netif.c +++ b/components/esp_wifi/src/wifi_netif.c @@ -83,6 +83,11 @@ static esp_err_t wifi_driver_start(esp_netif_t * esp_netif, void * args) void esp_wifi_destroy_if_driver(wifi_netif_driver_t h) { + if (h) { + esp_wifi_internal_reg_rxcb(h->wifi_if, NULL); // ignore the potential error + // as the wifi might have been already uninitialized + s_wifi_netifs[h->wifi_if] = NULL; + } free(h); }