OSDN Git Service

Fix a race condition in the HCI module start_up()
authorPavlin Radoslavov <pavlin@google.com>
Tue, 1 Dec 2015 01:15:23 +0000 (17:15 -0800)
committerPavlin Radoslavov <pavlin@google.com>
Tue, 1 Dec 2015 01:15:23 +0000 (17:15 -0800)
commitc3e8824f8d5266ee5d33be18c690b8de8f0562aa
tree2e63ae147d3a75c96bae3ab93792570104490967
parentdd339ab075d913334c84fe4c817c8ab09f5eda47
Fix a race condition in the HCI module start_up()

* Fix a race condition when using the static startup_future
  inside hci_layer.c
  The future_new() allocation happens inside function start_up()
  and the allocated "startup_future" value is returned, so the caller can
  call future_await(future).
  However, if firmware_config_callback() is called on another thread
  BEFORE the "return startup_future;" statement is reached, then
  "startup_future" is reset to NULL. As a result, the caller
  will call future_await(NULL), and we have memory leak: startup_future
  is never freed.

* Fix other similar potential race conditions inside stack_manager.c
  where the static "hack_future" variable could be reassigned between
  the future_new() and future_await() calls.

Bug: 25766403
Change-Id: I0ef1165efba7412c190dfa2a7660189b28fa78a6
btif/src/stack_manager.c
hci/src/hci_layer.c