diff --git a/examples/protocols/pppos_client/components/modem/src/esp_modem_netif.c b/examples/protocols/pppos_client/components/modem/src/esp_modem_netif.c index e04e822086..42ed94d9db 100644 --- a/examples/protocols/pppos_client/components/modem/src/esp_modem_netif.c +++ b/examples/protocols/pppos_client/components/modem/src/esp_modem_netif.c @@ -109,7 +109,6 @@ drv_create_failed: void esp_modem_netif_teardown(void *h) { esp_modem_netif_driver_t *driver = h; - esp_netif_destroy(driver->base.netif); free(driver); } diff --git a/examples/protocols/pppos_client/main/pppos_client_main.c b/examples/protocols/pppos_client/main/pppos_client_main.c index a3cb2ad0fe..c312837cd0 100644 --- a/examples/protocols/pppos_client/main/pppos_client_main.c +++ b/examples/protocols/pppos_client/main/pppos_client_main.c @@ -294,9 +294,10 @@ void app_main(void) esp_mqtt_client_destroy(mqtt_client); /* Exit PPP mode */ ESP_ERROR_CHECK(esp_modem_stop_ppp(dte)); - /* Destroy the netif adapter withe events, which internally frees also the esp-netif instance */ + /* Unregister events, destroy the netif adapter and destroy its esp-netif instance */ esp_modem_netif_clear_default_handlers(modem_netif_adapter); esp_modem_netif_teardown(modem_netif_adapter); + esp_netif_destroy(esp_netif); xEventGroupWaitBits(event_group, STOP_BIT, pdTRUE, pdTRUE, portMAX_DELAY); #if CONFIG_EXAMPLE_SEND_MSG const char *message = "Welcome to ESP32!"; diff --git a/tools/test_apps/protocols/pppos/main/pppos_client_main.c b/tools/test_apps/protocols/pppos/main/pppos_client_main.c index 37961cf6fd..cfc0a7957d 100644 --- a/tools/test_apps/protocols/pppos/main/pppos_client_main.c +++ b/tools/test_apps/protocols/pppos/main/pppos_client_main.c @@ -258,9 +258,11 @@ void app_main(void) ESP_ERROR_CHECK(esp_modem_stop_ppp(dte)); /* Wait for the PPP connection to terminate gracefully */ xEventGroupWaitBits(event_group, DISCONNECT_BIT, pdTRUE, pdTRUE, portMAX_DELAY); - /* Destroy the netif adapter withe events, which internally frees also the esp-netif instance */ + /* Unregister events, destroy the netif adapter and destroy its esp-netif instance */ esp_modem_netif_clear_default_handlers(modem_netif_adapter); esp_modem_netif_teardown(modem_netif_adapter); + esp_netif_destroy(esp_netif); + xEventGroupWaitBits(event_group, STOP_BIT, pdTRUE, pdTRUE, portMAX_DELAY); ESP_ERROR_CHECK(dce->deinit(dce)); ESP_ERROR_CHECK(dte->deinit(dte));