nimble/l2cap: Fix for possible memory leak

With this patch we remove allocated memory for proc in case we could
not allocate signaling request later on.


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

Branch: refs/heads/1_0_0_dev
Commit: 45c365cff9bd4b14371707320fdc784b293576a5
Parents: f6b3b22
Author: Łukasz Rymanowski <[email protected]>
Authored: Wed Mar 1 09:24:35 2017 +0100
Committer: Marko Kiiskila <[email protected]>
Committed: Mon Mar 6 15:53:18 2017 -0800

----------------------------------------------------------------------
 net/nimble/host/src/ble_l2cap_sig.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/45c365cf/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 a33ddef..444a8f6 100644
--- a/net/nimble/host/src/ble_l2cap_sig.c
+++ b/net/nimble/host/src/ble_l2cap_sig.c
@@ -990,7 +990,8 @@ ble_l2cap_sig_disconnect(struct ble_l2cap_chan *chan)
     req = ble_l2cap_sig_cmd_get(BLE_L2CAP_SIG_OP_DISCONN_REQ, proc->id,
                                 sizeof(*req), &txom);
     if (!req) {
-        return BLE_HS_ENOMEM;
+        rc = BLE_HS_ENOMEM;
+        goto done;
     }
 
     req->dcid = htole16(chan->dcid);
@@ -998,6 +999,7 @@ ble_l2cap_sig_disconnect(struct ble_l2cap_chan *chan)
 
     rc = ble_l2cap_sig_tx(proc->conn_handle, txom);
 
+done:
     ble_l2cap_sig_process_status(proc, rc);
 
     return rc;

Reply via email to