Skip to content

Commit

Permalink
Fix UART deinit issues and crashes
Browse files Browse the repository at this point in the history
Remove interrupt callback before stopping thread
Prevents race condition of interrupt setting flag on free'd thread
Also correctly stop async rx events
  • Loading branch information
Willy-JL committed Mar 22, 2024
1 parent 245ee64 commit 7424373
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions applications/debug/uart_echo/uart_echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,14 @@ static UartEchoApp* uart_echo_app_alloc(uint32_t baudrate) {
static void uart_echo_app_free(UartEchoApp* app) {
furi_assert(app);

furi_hal_serial_async_rx_stop(app->serial_handle);
furi_hal_serial_deinit(app->serial_handle);
furi_hal_serial_control_release(app->serial_handle);

furi_thread_flags_set(furi_thread_get_id(app->worker_thread), WorkerEventStop);
furi_thread_join(app->worker_thread);
furi_thread_free(app->worker_thread);

furi_hal_serial_deinit(app->serial_handle);
furi_hal_serial_control_release(app->serial_handle);

// Free views
view_dispatcher_remove_view(app->view_dispatcher, 0);

Expand Down
1 change: 1 addition & 0 deletions applications/main/subghz/helpers/subghz_gps.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ SubGhzGPS* subghz_gps_init() {
void subghz_gps_deinit(SubGhzGPS* subghz_gps) {
furi_assert(subghz_gps);

furi_hal_serial_async_rx_stop(subghz_gps->serial_handle);
furi_hal_serial_deinit(subghz_gps->serial_handle);
furi_hal_serial_control_release(subghz_gps->serial_handle);

Expand Down

0 comments on commit 7424373

Please sign in to comment.