Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9bdfffdc authored by Myles Watson's avatar Myles Watson Committed by Andre Eisenbach
Browse files

hci: Close the HAL before cleaning up pending command queue and timers

This prevents errors in case of event callbacks being received or timers
being fired after the pending command queue has been deleted.

Bug: 36026072
Test: Turn Bluetooth off/on while scanning and file transfer
Change-Id: I7bb699e929a8b40e42a3543b5445885ae6b1b975
parent 7660d1ec
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -220,6 +220,14 @@ error:
static future_t* hci_module_shut_down() {
  LOG_INFO(LOG_TAG, "%s", __func__);

  // Free the timers
  alarm_free(command_response_timer);
  command_response_timer = NULL;
  alarm_free(startup_timer);
  startup_timer = NULL;

  hci_close();

  if (thread) {
    thread_stop(thread);
    thread_join(thread);
@@ -234,14 +242,6 @@ static future_t* hci_module_shut_down() {

  packet_fragmenter->cleanup();

  // Free the timers
  alarm_free(command_response_timer);
  command_response_timer = NULL;
  alarm_free(startup_timer);
  startup_timer = NULL;

  hci_close();

  thread_free(thread);
  thread = NULL;