OSDN Git Service

Check for control block nullptr on l2cap error
authorHansong Zhang <hsz@google.com>
Sun, 27 Sep 2020 23:30:03 +0000 (16:30 -0700)
committerHansong Zhang <hsz@google.com>
Mon, 28 Sep 2020 18:55:20 +0000 (11:55 -0700)
Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ie041822b2f51aa20e57fa35f90c432a6c96733d5

stack/avct/avct_l2c_br.cc
stack/bnep/bnep_main.cc
stack/gap/gap_conn.cc
stack/gatt/gatt_main.cc
stack/rfcomm/rfc_mx_fsm.cc
stack/sdp/sdp_main.cc

index a11ece8..7415c11 100644 (file)
@@ -103,6 +103,7 @@ void avct_l2c_br_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,
 
 void avct_br_on_l2cap_error(uint16_t lcid, uint16_t result) {
   tAVCT_BCB* p_lcb = avct_bcb_by_lcid(lcid);
+  if (p_lcb == nullptr) return;
 
   /* store result value */
   p_lcb->ch_result = result;
index ba3ee0f..1a25aab 100644 (file)
@@ -137,6 +137,7 @@ static void bnep_connect_ind(const RawAddress& bd_addr, uint16_t l2cap_cid,
 
 static void bnep_on_l2cap_error(uint16_t l2cap_cid, uint16_t result) {
   tBNEP_CONN* p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
+  if (p_bcb == nullptr) return;
 
   /* Tell the upper layer, if there is a callback */
   if ((p_bcb->con_flags & BNEP_FLAGS_IS_ORIG) && (bnep_cb.p_conn_state_cb)) {
index 13b12e7..d3e49aa 100644 (file)
@@ -687,6 +687,7 @@ static void gap_sec_check_complete(const RawAddress*, tBT_TRANSPORT,
 
 static void gap_on_l2cap_error(uint16_t l2cap_cid, uint16_t result) {
   tGAP_CCB* p_ccb = gap_find_ccb_by_cid(l2cap_cid);
+  if (p_ccb == nullptr) return;
 
   /* Tell the user if there is a callback */
   if (p_ccb->p_callback)
index 07d6190..aac3d24 100644 (file)
@@ -587,6 +587,7 @@ static void gatt_l2cif_connect_ind_cback(const RawAddress& bd_addr,
 
 static void gatt_on_l2cap_error(uint16_t lcid, uint16_t result) {
   tGATT_TCB* p_tcb = gatt_find_tcb_by_cid(lcid);
+  if (p_tcb == nullptr) return;
   if (gatt_get_ch_state(p_tcb) == GATT_CH_CONN) {
     gatt_cleanup_upon_disc(p_tcb->peer_bda, result, BT_TRANSPORT_BR_EDR);
   } else {
index 05ac960..511e590 100644 (file)
@@ -556,6 +556,7 @@ static void rfc_mx_send_config_req(tRFC_MCB* p_mcb) {
 
 void rfc_on_l2cap_error(uint16_t lcid, uint16_t result) {
   tRFC_MCB* p_mcb = rfc_find_lcid_mcb(lcid);
+  if (p_mcb == nullptr) return;
 
   if (result == L2CAP_CONN_OTHER_ERROR) {
     RFCOMM_TRACE_DEBUG(
index 5bd4807..ec49e4f 100644 (file)
@@ -131,6 +131,7 @@ static void sdp_connect_ind(const RawAddress& bd_addr, uint16_t l2cap_cid,
 
 static void sdp_on_l2cap_error(uint16_t l2cap_cid, uint16_t result) {
   tCONN_CB* p_ccb = sdpu_find_ccb_by_cid(l2cap_cid);
+  if (p_ccb == nullptr) return;
   sdp_disconnect(p_ccb, SDP_CFG_FAILED);
 }