aboutsummaryrefslogtreecommitdiff
path: root/stack/btm/btm_dev.cc
diff options
context:
space:
mode:
Diffstat (limited to 'stack/btm/btm_dev.cc')
-rw-r--r--stack/btm/btm_dev.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/stack/btm/btm_dev.cc b/stack/btm/btm_dev.cc
index 07332e7c1..0fe5c20e9 100644
--- a/stack/btm/btm_dev.cc
+++ b/stack/btm/btm_dev.cc
@@ -147,17 +147,16 @@ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
return true;
}
-/*******************************************************************************
- *
- * Function BTM_SecDeleteDevice
- *
- * Description Free resources associated with the device.
+/** Free resources associated with the device associated with |bd_addr| address.
*
- * Parameters: bd_addr - BD address of the peer
- *
- * Returns true if removed OK, false if not found or ACL link is active
+ * *** 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.
+ */
bool BTM_SecDeleteDevice(const RawAddress& bd_addr) {
if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE) ||
BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_BR_EDR)) {
@@ -168,9 +167,10 @@ bool BTM_SecDeleteDevice(const RawAddress& bd_addr) {
tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr);
if (p_dev_rec != NULL) {
+ RawAddress bda = p_dev_rec->bd_addr;
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;