MYNEWT-702 dbg: Erase mempool entries during free.

This behavior only takes effect when BLE_HS_DEBUG is enabled.  When a
host mempool entry is freed, it is memset to 0xff.  This will hopefully
help catch dangling pointer bugs.

X-Original-Commit: b8380e94765005b48bfeebe06dee2c2ac924da96
This commit is contained in:
Christopher Collins
2017-04-03 18:29:15 -07:00
parent 32b552e167
commit d64f4a4d9f
6 changed files with 18 additions and 1 deletions
+3
View File
@@ -2170,6 +2170,9 @@ ble_att_svr_prep_free(struct ble_att_prep_entry *entry)
{
if (entry != NULL) {
os_mbuf_free_chain(entry->bape_value);
#if MYNEWT_VAL(BLE_HS_DEBUG)
memset(entry, 0xff, sizeof *entry);
#endif
os_memblock_put(&ble_att_svr_prep_entry_pool, entry);
}
}
+3
View File
@@ -710,6 +710,9 @@ ble_gattc_proc_free(struct ble_gattc_proc *proc)
break;
}
#if MYNEWT_VAL(BLE_HS_DEBUG)
memset(proc, 0xff, sizeof *proc);
#endif
rc = os_memblock_put(&ble_gattc_proc_pool, proc);
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
}
+3
View File
@@ -217,6 +217,9 @@ ble_hs_conn_free(struct ble_hs_conn *conn)
ble_hs_conn_delete_chan(conn, chan);
}
#if MYNEWT_VAL(BLE_HS_DEBUG)
memset(conn, 0xff, sizeof *conn);
#endif
rc = os_memblock_put(&ble_hs_conn_pool, conn);
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
+3
View File
@@ -81,6 +81,9 @@ ble_l2cap_chan_free(struct ble_l2cap_chan *chan)
os_mbuf_free_chain(chan->rx_buf);
ble_l2cap_coc_cleanup_chan(chan);
#if MYNEWT_VAL(BLE_HS_DEBUG)
memset(chan, 0xff, sizeof *chan);
#endif
rc = os_memblock_put(&ble_l2cap_chan_pool, chan);
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
+3
View File
@@ -206,6 +206,9 @@ ble_l2cap_sig_proc_free(struct ble_l2cap_sig_proc *proc)
if (proc != NULL) {
ble_l2cap_sig_dbg_assert_proc_not_inserted(proc);
#if MYNEWT_VAL(BLE_HS_DEBUG)
memset(proc, 0xff, sizeof *proc);
#endif
rc = os_memblock_put(&ble_l2cap_sig_proc_pool, proc);
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
}
+3 -1
View File
@@ -393,7 +393,9 @@ ble_sm_proc_free(struct ble_sm_proc *proc)
if (proc != NULL) {
ble_sm_dbg_assert_not_inserted(proc);
#if MYNEWT_VAL(BLE_HS_DEBUG)
memset(proc, 0xff, sizeof *proc);
#endif
rc = os_memblock_put(&ble_sm_proc_pool, proc);
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
}