From b77d7129b2dff50e80dd910b02a11290011dbc62 Mon Sep 17 00:00:00 2001 From: Pavlin Radoslavov Date: Thu, 23 Mar 2017 12:24:57 -0700 Subject: [PATCH] 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 --- hci/src/hci_layer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hci/src/hci_layer.cc b/hci/src/hci_layer.cc index dcb1d84b0..9ac3b70e6 100644 --- a/hci/src/hci_layer.cc +++ b/hci/src/hci_layer.cc @@ -396,7 +396,6 @@ static void command_timed_out(UNUSED_ATTR void* context) { } else { waiting_command_t* wait_entry = reinterpret_cast( 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__); -- 2.11.0