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/448dfaca Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/448dfaca Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/448dfaca Branch: refs/heads/develop Commit: 448dfacaaf933720dec4280f8cd92bd8259ad3e0 Parents: 2ec94a1 Author: Christopher Collins <[email protected]> Authored: Fri Aug 5 12:16:40 2016 -0700 Committer: Christopher Collins <[email protected]> Committed: Sat Aug 6 14:15:59 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/448dfaca/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);
