summaryrefslogtreecommitdiffstats
path: root/stack/btm/btm_dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'stack/btm/btm_dev.c')
-rw-r--r--stack/btm/btm_dev.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/stack/btm/btm_dev.c b/stack/btm/btm_dev.c
index 78af31ffb..9baa73a3e 100644
--- a/stack/btm/btm_dev.c
+++ b/stack/btm/btm_dev.c
@@ -172,17 +172,16 @@ BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name,
}
-/*******************************************************************************
-**
-** 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;
@@ -196,9 +195,11 @@ BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr)
if ((p_dev_rec = btm_find_dev(bd_addr)) != 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;