Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95c949f4 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Fix for connection attempt after connection cancel

When connection attempt is canceled, we put the transport control block
(p_tcb) into CLOSING state, but we never close or free it.
For LE devices that have not established the connection, it's safe to
go straight to CLOSED state and free the p_tcb.

This issue was introduced during connection manager refactor.

Bug: 127242749
Test: GattConnectTest
Change-Id: I8e45ead9b071c60e95d2e60dcea8afdbaefb92b1
parent aab93bff
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -242,8 +242,9 @@ bool gatt_disconnect(tGATT_TCB* p_tcb) {
      /* only LCB exist between remote device and local */
      ret = L2CA_RemoveFixedChnl(L2CAP_ATT_CID, p_tcb->peer_bda);
    } else {
      ret = L2CA_CancelBleConnectReq(p_tcb->peer_bda);
      if (!ret) gatt_set_ch_state(p_tcb, GATT_CH_CLOSE);
      L2CA_CancelBleConnectReq(p_tcb->peer_bda);
      gatt_cleanup_upon_disc(p_tcb->peer_bda, HCI_ERR_CONN_CAUSE_LOCAL_HOST, p_tcb->transport);
      return true;
    }
    gatt_set_ch_state(p_tcb, GATT_CH_CLOSING);
  } else {
@@ -356,6 +357,7 @@ bool gatt_act_connect(tGATT_REG* p_reg, const RawAddress& bd_addr,
                        p_reg->gatt_if))
        return false;
    } else if (st == GATT_CH_CLOSING) {
      LOG(INFO) << "Must finish disconnection before new connection";
      /* need to complete the closing first */
      return false;
    }