You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ry...@apache.org on 2020/03/12 13:03:57 UTC

[mynewt-nimble] 02/03: nimble/l2cap: Fix hs locking on reconfigure request

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

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

commit 7bc2227df870be557552c723df0b1ec1c0752809
Author: Ɓukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Wed Mar 11 20:48:36 2020 +0100

    nimble/l2cap: Fix hs locking on reconfigure request
---
 nimble/host/src/ble_l2cap_sig.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/nimble/host/src/ble_l2cap_sig.c b/nimble/host/src/ble_l2cap_sig.c
index 9252ce5..165af91 100644
--- a/nimble/host/src/ble_l2cap_sig.c
+++ b/nimble/host/src/ble_l2cap_sig.c
@@ -750,14 +750,14 @@ ble_l2cap_sig_credit_base_reconfig_req_rx(uint16_t conn_handle,
 
     if (hdr->length <= sizeof(*req)) {
         rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_UNACCAPTED_PARAM);
-        goto done;
+        goto failed;
     }
 
     req = (struct ble_l2cap_sig_credit_base_reconfig_req *)(*om)->om_data;
 
     if ((req->mps < BLE_L2CAP_ECOC_MIN_MTU) || (req->mtu < BLE_L2CAP_ECOC_MIN_MTU)) {
         rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_UNACCAPTED_PARAM);
-        goto done;
+        goto failed;
     }
 
     /* Assume request will succeed. If not, result will be updated */
@@ -766,41 +766,43 @@ ble_l2cap_sig_credit_base_reconfig_req_rx(uint16_t conn_handle,
     cid_cnt = (hdr->length - sizeof(*req)) / sizeof(uint16_t);
     if (cid_cnt > BLE_L2CAP_MAX_COC_CONN_REQ) {
         rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_UNACCAPTED_PARAM);
-        goto done;
+        goto failed;
     }
 
     for (i = 0; i < cid_cnt; i++) {
         chan[i] = ble_hs_conn_chan_find_by_dcid(conn, req->dcids[i]);
         if (!chan[i]) {
              rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_INVALID_DCID);
-             ble_hs_unlock();
-             goto done;
+             goto failed;
         }
 
         if (chan[i]->peer_coc_mps > req->mps) {
             reduction_mps++;
             if (reduction_mps > 1) {
                 rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MPS_NOT_ALLOWED);
-                ble_hs_unlock();
-                goto done;
+                goto failed;
             }
         }
 
         if (chan[i]->coc_tx.mtu > req->mtu) {
             rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MTU_NOT_ALLOWED);
-            ble_hs_unlock();
-            goto done;
+            goto failed;
         }
     }
 
+    ble_hs_unlock();
+
     for (i = 0; i < cid_cnt; i++) {
         chan[i]->coc_tx.mtu = req->mtu;
         chan[i]->peer_coc_mps = req->mps;
         ble_l2cap_event_coc_reconfigured(conn_handle, 0, chan[i], true);
     }
 
+    ble_l2cap_sig_tx(conn_handle, txom);
+    return 0;
+
+failed:
     ble_hs_unlock();
-done:
     ble_l2cap_sig_tx(conn_handle, txom);
     return 0;
 }