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

Commit e95427f8 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Fix a race condition inside command_timed_out() when printing log info

Release the lock after we don't need anymore access to the wait_entry
that was protected by the lock.
Note: We are keeping the lock right before restarting the Bluetooth
process, hence it doesn't matter we are holding it for a bit longer
than before.

Test: Code compilation
Change-Id: Id393a285fce9b9e28efcf0f55fcc32821c5a72b6
parent 0054ab48
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -396,7 +396,6 @@ static void command_timed_out(UNUSED_ATTR void* context) {
  } else {
    waiting_command_t* wait_entry = reinterpret_cast<waiting_command_t*>(
        list_front(commands_pending_response));
    lock.unlock();

    // We shouldn't try to recover the stack from this command timeout.
    // If it's caused by a software bug, fix it. If it's a hardware bug, fix it.
@@ -405,6 +404,7 @@ static void command_timed_out(UNUSED_ATTR void* context) {
        "%s hci layer timeout waiting for response to a command. opcode: 0x%x",
        __func__, wait_entry->opcode);
    LOG_EVENT_INT(BT_HCI_TIMEOUT_TAG_NUM, wait_entry->opcode);
    lock.unlock();
  }

  LOG_ERROR(LOG_TAG, "%s restarting the bluetooth process.", __func__);