You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/08/09 23:08:04 UTC

[30/42] incubator-mynewt-core git commit: BLE Host - Free mbuf on os_mqueue_put() failure.

BLE Host - Free mbuf on os_mqueue_put() failure.

This fixes a theoretical mbuf leak.  In practice, the call to
os_mqueue_put() will never fail.


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/259f4c3b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/259f4c3b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/259f4c3b

Branch: refs/heads/sterly_refactor
Commit: 259f4c3bfc72afdd69c78b82ffbc43fc9d2a39d8
Parents: a449b70
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Aug 5 12:16:40 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Tue Aug 9 16:05:21 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_hs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/259f4c3b/net/nimble/host/src/ble_hs.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c
index 225b26c..02db879 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -496,6 +496,15 @@ ble_hs_rx_data(struct os_mbuf *om, void *arg)
     return rc;
 }
 
+/**
+ * Enqueues an ACL data packet for transmission.  This function consumes the
+ * supplied mbuf, regardless of the outcome.
+ *
+ * @param om                    The outgoing data packet, beginning with the
+ *                                  HCI ACL data header.
+ *
+ * @return                      0 on success; nonzero on failure.
+ */
 int
 ble_hs_tx_data(struct os_mbuf *om)
 {
@@ -503,6 +512,7 @@ ble_hs_tx_data(struct os_mbuf *om)
 
     rc = os_mqueue_put(&ble_hs_tx_q, &ble_hs_evq, om);
     if (rc != 0) {
+        os_mbuf_free_chain(om);
         return BLE_HS_EOS;
     }
     os_eventq_put(ble_hs_parent_evq, &ble_hs_event_co.cf_c.c_ev);