OSDN Git Service

[automerger] Don't use Address after it was deleted am: 228712652a am: 4530549386
authorAndroid Build Merger (Role) <noreply-android-build-merger@google.com>
Fri, 13 Jul 2018 06:58:15 +0000 (06:58 +0000)
committerAndroid Build Merger (Role) <noreply-android-build-merger@google.com>
Fri, 13 Jul 2018 06:58:15 +0000 (06:58 +0000)
Change-Id: I29002bb4e25f3c026c144f03db577fbdf7ebddf4

1  2 
bta/dm/bta_dm_act.c
stack/btm/btm_dev.c
stack/include/btm_api.h

Simple merge
@@@ -157,19 -164,20 +157,18 @@@ BOOLEAN BTM_SecAddDevice (BD_ADDR bd_ad
  }
  
  
- /*******************************************************************************
- **
- ** Function         BTM_SecDeleteDevice
- **
- ** Description      Free resources associated with the device.
- **
- ** Parameters:      bd_addr          - BD address of the peer
- **
- ** Returns          TRUE if removed OK, FALSE if not found or ACL link is active
- **
- *******************************************************************************/
+ /** Free resources associated with the device associated with |bd_addr| address.
+  *
+  * *** WARNING ***
+  * tBTM_SEC_DEV_REC associated with bd_addr becomes invalid after this function
+  * is called, also any of it's fields. i.e. if you use p_dev_rec->bd_addr, it is
+  * no longer valid!
+  * *** WARNING ***
+  *
+  * Returns true if removed OK, false if not found or ACL link is active.
+  */
  BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr)
  {
 -    tBTM_SEC_DEV_REC *p_dev_rec;
 -
      if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE) ||
          BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_BR_EDR))
      {
          return FALSE;
      }
  
 -    if ((p_dev_rec = btm_find_dev(bd_addr)) != NULL)
 +    tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(bd_addr);
 +    if (p_dev_rec != NULL)
      {
+         BD_ADDR bda;
+         memcpy(bda, bd_addr, BD_ADDR_LEN);
          btm_sec_free_dev(p_dev_rec);
          /* Tell controller to get rid of the link key, if it has one stored */
-         BTM_DeleteStoredLinkKey (p_dev_rec->bd_addr, NULL);
+         BTM_DeleteStoredLinkKey (bda, NULL);
      }
  
      return TRUE;
@@@ -3313,26 -3313,18 +3313,27 @@@ extern BOOLEAN BTM_SecAddDevice (BD_ADD
                                   UINT8 key_type, tBTM_IO_CAP io_cap, UINT8 pin_length);
  
  
- /*******************************************************************************
- **
- ** Function         BTM_SecDeleteDevice
- **
- ** Description      Free resources associated with the device.
- **
- ** Returns          TRUE if rmoved OK, FALSE if not found
- **
- *******************************************************************************/
+ /** Free resources associated with the device associated with |bd_addr| address.
+  *
+  * *** WARNING ***
+  * tBTM_SEC_DEV_REC associated with bd_addr becomes invalid after this function
+  * is called, also any of it's fields. i.e. if you use p_dev_rec->bd_addr, it is
+  * no longer valid!
+  * *** WARNING ***
+  *
+  * Returns true if removed OK, false if not found or ACL link is active.
+  */
  extern BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr);
  
 +/*******************************************************************************
 +**
 +** Function         BTM_SecClearSecurityFlags
 +**
 +** Description      Reset the security flags (mark as not-paired) for a given
 +**                  remove device.
 +**
 +*******************************************************************************/
 +extern void BTM_SecClearSecurityFlags (BD_ADDR bd_addr);
  
  /*******************************************************************************
  **