]> granicus.if.org Git - esp-idf/commitdiff
VFS: Fix memory access after free() in UART select()
authorRoland Dobai <roland@espressif.com>
Mon, 9 Sep 2019 13:02:38 +0000 (15:02 +0200)
committerbot <bot@espressif.com>
Tue, 10 Sep 2019 04:59:03 +0000 (04:59 +0000)
Closes https://github.com/espressif/esp-idf/issues/4030

components/vfs/vfs_uart.c

index f1513ae1dcca4a371527f4fa93f002744297c953..7e02ef963d8249ae45388e8ea2f4b6bdf902b058 100644 (file)
@@ -474,10 +474,6 @@ static esp_err_t uart_end_select(void *end_select_args)
 {
     uart_select_args_t *args = end_select_args;
 
-    if (args) {
-        free(args);
-    }
-
     portENTER_CRITICAL(uart_get_selectlock());
     esp_err_t ret = unregister_select(args);
     for (int i = 0; i < UART_NUM; ++i) {
@@ -485,6 +481,10 @@ static esp_err_t uart_end_select(void *end_select_args)
     }
     portEXIT_CRITICAL(uart_get_selectlock());
 
+    if (args) {
+        free(args);
+    }
+
     return ret;
 }