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

Commit ad14bdc4 authored by Hui Peng's avatar Hui Peng
Browse files

Fix a nullptr check failure in list_foreach

During reset, when btm_sec_cb.sec_dev_rec becomes null and
encyption events is sent to the host, nullptr check
failure will cause the stack to crash.

Bug: 324655049
Test: m com.android.btservices
Test: see aosp/2879087
Flag: EXEMPT, add null check
Change-Id: I33052b78c8989930c8c9dbdb49924e5c230266c3
parent 35d2974f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -372,6 +372,8 @@ static bool is_handle_equal(void* data, void* context) {
 *
 ******************************************************************************/
tBTM_SEC_DEV_REC* btm_find_dev_by_handle(uint16_t handle) {
  if (btm_sec_cb.sec_dev_rec == nullptr) return nullptr;

  list_node_t* n =
      list_foreach(btm_sec_cb.sec_dev_rec, is_handle_equal, &handle);
  if (n) return static_cast<tBTM_SEC_DEV_REC*>(list_node(n));