OSDN Git Service

btm_acl_removed: Check for null as acl may have already closed
authorChris Manton <cmanton@google.com>
Mon, 26 Oct 2020 16:16:50 +0000 (09:16 -0700)
committerChris Manton <cmanton@google.com>
Mon, 26 Oct 2020 16:24:32 +0000 (09:24 -0700)
Bug:159815595
Tag: #refactor
Test: acts.py BleCocTest

Change-Id: I7a5312d4d929280de73442885100714264cd1457

stack/acl/btm_acl.cc

index 5d7a43f..41f0226 100644 (file)
@@ -470,15 +470,15 @@ void btm_acl_update_conn_addr(uint16_t conn_handle, const RawAddress& address) {
  ******************************************************************************/
 void btm_acl_removed(uint16_t handle) {
   tACL_CONN* p_acl = internal_.acl_get_connection_from_handle(handle);
+  if (p_acl == nullptr) {
+    LOG_WARN("Unable to find active acl");
+    return;
+  }
   RawAddress bda = p_acl->remote_addr;
   tBT_TRANSPORT transport = p_acl->transport;
   if (transport == BT_TRANSPORT_LE) {
     bda = p_acl->conn_addr;
   }
-  if (p_acl == nullptr) {
-    LOG_WARN("Unable to find active acl");
-    return;
-  }
   p_acl->in_use = false;
 
   /* Only notify if link up has had a chance to be issued */