From e72151055b3c0a076cdaa575012f937835f83dc2 Mon Sep 17 00:00:00 2001 From: Krzysztof Lewandowski Date: Thu, 14 Apr 2022 14:42:30 +0200 Subject: [PATCH] esp_wifi: fix clearing default wifi netif procedure Prior to this change "esp_wifi_clear_default_wifi_driver_and_handlers" will not remove netif pointer from table when both AP and STA interfaces were created and destroying default wifi interfaces is done in unfortunate order. As a result there is dangling pointer left and it may cause crash in later code (i.e. when esp_wifi_stop() is called). --- components/esp_wifi/src/wifi_default.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/esp_wifi/src/wifi_default.c b/components/esp_wifi/src/wifi_default.c index 8097c445b2..0854a1b0fb 100644 --- a/components/esp_wifi/src/wifi_default.c +++ b/components/esp_wifi/src/wifi_default.c @@ -236,6 +236,8 @@ esp_err_t esp_wifi_clear_default_wifi_driver_and_handlers(void *esp_netif) if (s_wifi_netifs[i] == esp_netif) { s_wifi_netifs[i] = NULL; } + } + for (i = 0; i< MAX_WIFI_IFS; ++i) { // check if all netifs are cleared to delete default handlers if (s_wifi_netifs[i] != NULL) { break;