You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2017/04/07 18:45:01 UTC

[27/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-702 dbg: Erase mempool entries during free.

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.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b8380e94
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b8380e94
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b8380e94

Branch: refs/heads/master
Commit: b8380e94765005b48bfeebe06dee2c2ac924da96
Parents: e33dbd4
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Apr 3 18:24:26 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Apr 3 18:29:15 2017 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_att_svr.c   | 3 +++
 net/nimble/host/src/ble_gattc.c     | 3 +++
 net/nimble/host/src/ble_hs_conn.c   | 3 +++
 net/nimble/host/src/ble_l2cap.c     | 3 +++
 net/nimble/host/src/ble_l2cap_sig.c | 3 +++
 net/nimble/host/src/ble_sm.c        | 4 +++-
 6 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b8380e94/net/nimble/host/src/ble_att_svr.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c
index 1775292..5ca2c87 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -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);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b8380e94/net/nimble/host/src/ble_gattc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gattc.c b/net/nimble/host/src/ble_gattc.c
index 40f4c5c..917e21a 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -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);
     }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b8380e94/net/nimble/host/src/ble_hs_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_conn.c b/net/nimble/host/src/ble_hs_conn.c
index cef0e3a..470f377 100644
--- a/net/nimble/host/src/ble_hs_conn.c
+++ b/net/nimble/host/src/ble_hs_conn.c
@@ -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);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b8380e94/net/nimble/host/src/ble_l2cap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap.c b/net/nimble/host/src/ble_l2cap.c
index b19a348..570498a 100644
--- a/net/nimble/host/src/ble_l2cap.c
+++ b/net/nimble/host/src/ble_l2cap.c
@@ -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);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b8380e94/net/nimble/host/src/ble_l2cap_sig.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_sig.c b/net/nimble/host/src/ble_l2cap_sig.c
index 1840b0a..c9c1886 100644
--- a/net/nimble/host/src/ble_l2cap_sig.c
+++ b/net/nimble/host/src/ble_l2cap_sig.c
@@ -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);
     }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b8380e94/net/nimble/host/src/ble_sm.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm.c b/net/nimble/host/src/ble_sm.c
index ef2f41b..82c3724 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -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);
     }