Merge branch 'bugfix/access_nullptr_when_ble_disconn_v5.0' into 'release/v5.0'

Bugfix/Fixed crash caused by accessing nullptr in `btm_acl_disconnected` (v5.0)

See merge request espressif/esp-idf!21879
This commit is contained in:
Wang Meng Yang
2023-02-21 18:18:48 +08:00

View File

@ -2657,14 +2657,22 @@ void btm_acl_connected(BD_ADDR bda, UINT16 handle, UINT8 link_type, UINT8 enc_mo
*******************************************************************************/
void btm_acl_disconnected(UINT16 handle, UINT8 reason)
{
BOOLEAN need_report = TRUE;
#if BTM_SCO_INCLUDED == TRUE
/* If L2CAP doesn't know about it, send it to SCO */
if (!l2c_link_hci_disc_comp (handle, reason)) {
btm_sco_removed (handle, reason);
need_report = FALSE;
}
#else
l2c_link_hci_disc_comp(handle, reason);
#endif /* BTM_SCO_INCLUDED */
if (need_report) {
/* Report BR/EDR ACL disconnection result to upper layer */
tACL_CONN *conn = btm_handle_to_acl(handle);
if (conn) {
#if BLE_INCLUDED == TRUE
if (conn->transport == BT_TRANSPORT_BR_EDR)
#endif
@ -2677,9 +2685,9 @@ void btm_acl_disconnected(UINT16 handle, UINT8 reason)
bdcpy(evt_data.link_act.disconn_cmpl.bd_addr, conn->remote_addr);
btm_acl_link_stat_report(&evt_data);
}
}
}
l2c_link_hci_disc_comp(handle, reason);
#endif /* BTM_SCO_INCLUDED */
#if (SMP_INCLUDED == TRUE)
/* Notify security manager */
btm_sec_disconnected(handle, reason);