From 4759f1a1198f03d8e105d7bf47964f8b86cc4373 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Thu, 21 Jan 2021 11:25:38 -0800 Subject: [PATCH] Fix btm_sco_connected usage Don't invoke when bda is nullptr. Test: cert/run Tag: #gd-refactor Bug: 141555841 Change-Id: I2509e905849c6b9e224242e2486a8e3496e6314a --- stack/btm/btm_sco.cc | 10 ++++------ stack/btu/btu_hcif.cc | 6 ++---- stack/include/sco_hci_link_interface.h | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/stack/btm/btm_sco.cc b/stack/btm/btm_sco.cc index 92a7f5edc..3782685d5 100644 --- a/stack/btm/btm_sco.cc +++ b/stack/btm/btm_sco.cc @@ -683,7 +683,7 @@ void btm_sco_conn_req(const RawAddress& bda, DEV_CLASS dev_class, * Returns void * ******************************************************************************/ -void btm_sco_connected(uint8_t hci_status, const RawAddress* bda, +void btm_sco_connected(uint8_t hci_status, const RawAddress& bda, uint16_t hci_handle, tBTM_ESCO_DATA* p_esco_data) { tSCO_CONN* p = &btm_cb.sco_cb.sco_db[0]; uint16_t xx; @@ -693,7 +693,7 @@ void btm_sco_connected(uint8_t hci_status, const RawAddress* bda, for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) { if (((p->state == SCO_ST_CONNECTING) || (p->state == SCO_ST_LISTENING) || (p->state == SCO_ST_W4_CONN_RSP)) && - (p->rem_bd_known) && (!bda || p->esco.data.bd_addr == *bda)) { + (p->rem_bd_known) && (p->esco.data.bd_addr == bda)) { if (hci_status != HCI_SUCCESS) { /* Report the error if originator, otherwise remain in Listen mode */ if (p->is_orig) { @@ -726,15 +726,13 @@ void btm_sco_connected(uint8_t hci_status, const RawAddress* bda, p->state = SCO_ST_CONNECTED; p->hci_handle = hci_handle; - RawAddress bd_addr(*bda); - if (hci_status == HCI_SUCCESS) { - BTM_LogHistory(kBtmLogTag, bd_addr, "Connection success", + BTM_LogHistory(kBtmLogTag, bda, "Connection success", base::StringPrintf("handle:0x%04x %s", hci_handle, (spt) ? "listener" : "initiator")); } else { BTM_LogHistory( - kBtmLogTag, bd_addr, "Connection failed", + kBtmLogTag, bda, "Connection failed", base::StringPrintf( "reason:%s", hci_reason_code_text(static_cast(hci_status)) diff --git a/stack/btu/btu_hcif.cc b/stack/btu/btu_hcif.cc index d06bf2601..9d2aff6fb 100644 --- a/stack/btu/btu_hcif.cc +++ b/stack/btu/btu_hcif.cc @@ -962,7 +962,7 @@ static void btu_hcif_connection_comp_evt(uint8_t* p, uint8_t evt_len) { memset(&esco_data, 0, sizeof(tBTM_ESCO_DATA)); /* esco_data.link_type = HCI_LINK_TYPE_SCO; already zero */ esco_data.bd_addr = bda; - btm_sco_connected(status, &bda, handle, &esco_data); + btm_sco_connected(status, bda, handle, &esco_data); } } @@ -1178,7 +1178,7 @@ static void btu_hcif_esco_connection_comp_evt(uint8_t* p) { handle = HCID_GET_HANDLE(handle); data.bd_addr = bda; - btm_sco_connected(status, &bda, handle, &data); + btm_sco_connected(status, bda, handle, &data); } /******************************************************************************* @@ -1437,8 +1437,6 @@ static void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status, // Determine if initial connection failed or is a change of setup if (btm_is_sco_active(handle)) { btm_esco_proc_conn_chg(status, handle, 0, 0, 0, 0); - } else { - btm_sco_connected(status, nullptr, handle, nullptr); } } break; diff --git a/stack/include/sco_hci_link_interface.h b/stack/include/sco_hci_link_interface.h index 065651d05..f43c5dcd4 100644 --- a/stack/include/sco_hci_link_interface.h +++ b/stack/include/sco_hci_link_interface.h @@ -32,7 +32,7 @@ extern void btm_sco_chk_pend_unpark(tHCI_STATUS hci_status, uint16_t hci_handle); extern void btm_sco_conn_req(const RawAddress& bda, DEV_CLASS dev_class, uint8_t link_type); -extern void btm_sco_connected(uint8_t hci_status, const RawAddress* bda, +extern void btm_sco_connected(uint8_t hci_status, const RawAddress& bda, uint16_t hci_handle, tBTM_ESCO_DATA* p_esco_data); extern bool btm_sco_removed(uint16_t hci_handle, tHCI_REASON reason); -- 2.11.0