This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new 7c581b0  nimble/host: Fix txom leaks in ble_sm_tx and ble_l2cap_sig_tx
7c581b0 is described below

commit 7c581b0734406fd1ed698a11e54c69940b01ed5e
Author: Szymon Janc <szymon.j...@codecoup.pl>
AuthorDate: Mon Jul 12 14:49:01 2021 +0200

    nimble/host: Fix txom leaks in ble_sm_tx and ble_l2cap_sig_tx
    
    Those functions are expected to always consume txom.
---
 nimble/host/src/ble_l2cap_sig_cmd.c | 3 +++
 nimble/host/src/ble_sm_cmd.c        | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/nimble/host/src/ble_l2cap_sig_cmd.c 
b/nimble/host/src/ble_l2cap_sig_cmd.c
index d9e507e..48b3524 100644
--- a/nimble/host/src/ble_l2cap_sig_cmd.c
+++ b/nimble/host/src/ble_l2cap_sig_cmd.c
@@ -21,6 +21,7 @@
 #include "ble_hs_priv.h"
 
 #if NIMBLE_BLE_CONNECT
+/* this function consumes tx os_mbuf */
 int
 ble_l2cap_sig_tx(uint16_t conn_handle, struct os_mbuf *txom)
 {
@@ -33,6 +34,8 @@ ble_l2cap_sig_tx(uint16_t conn_handle, struct os_mbuf *txom)
                                          &conn, &chan);
     if (rc == 0) {
         rc = ble_l2cap_tx(conn, chan, txom);
+    } else {
+        os_mbuf_free_chain(txom);
     }
     ble_hs_unlock();
 
diff --git a/nimble/host/src/ble_sm_cmd.c b/nimble/host/src/ble_sm_cmd.c
index 2983102..b84df1e 100644
--- a/nimble/host/src/ble_sm_cmd.c
+++ b/nimble/host/src/ble_sm_cmd.c
@@ -63,6 +63,8 @@ ble_sm_tx(uint16_t conn_handle, struct os_mbuf *txom)
                                          &conn, &chan);
     if (rc == 0) {
         rc = ble_l2cap_tx(conn, chan, txom);
+    } else {
+        os_mbuf_free_chain(txom);
     }
 
     return rc;

Reply via email to