From 90cdceac392b1e6db9497028838d32242c7b7c11 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 3 Jul 2020 13:31:57 +0200 Subject: [PATCH] esp-modem: Remove esp-netif destroy from modem network glue code To be in line with other interfaces, when deleting the driver and it's glue layer to esp-netif, we DO NOT delete the related esp-netif (since is was allocated and created outside of the glue code and it works the same way in esp-eth and esp-wifi driver/glue layers). Closes https://github.com/espressif/esp-idf/issues/5486 --- .../pppos_client/components/modem/src/esp_modem_netif.c | 1 - examples/protocols/pppos_client/main/pppos_client_main.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) 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 bcddf66867..1c6f4bcf19 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 @@ -129,7 +129,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 c4b5fd8ab0..4b34395b03 100644 --- a/examples/protocols/pppos_client/main/pppos_client_main.c +++ b/examples/protocols/pppos_client/main/pppos_client_main.c @@ -279,9 +279,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!";