From a0ae67ef8bef8fd45a819435f01e454b4a67be67 Mon Sep 17 00:00:00 2001 From: linruihao Date: Fri, 21 Mar 2025 10:48:14 +0800 Subject: [PATCH] fix(bt/bluedroid): Fix some bugs in Bluedroid - Fix PBAC may free undefine memory when conn failed - Fix some memory in OBEX not being freed when bluedroid deinit - Fix pre-commit not check some source file that we added to bluedroid --- .../btc/profile/std/pba/btc_pba_client.c | 19 ++++++++----------- .../bt/host/bluedroid/stack/obex/obex_api.c | 4 ++-- tools/ci/check_copyright_config.yaml | 3 +++ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/bt/host/bluedroid/btc/profile/std/pba/btc_pba_client.c b/components/bt/host/bluedroid/btc/profile/std/pba/btc_pba_client.c index f1ef0981f3..ede18df37a 100644 --- a/components/bt/host/bluedroid/btc/profile/std/pba/btc_pba_client.c +++ b/components/bt/host/bluedroid/btc/profile/std/pba/btc_pba_client.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -855,17 +855,14 @@ void btc_pba_client_cb_handler(btc_msg_t *msg) btc_queue_advance(); break; case BTA_PBA_CLIENT_CONN_CLOSE_EVT: - /* clear ccb */ - p_ccb = &btc_pba_client_cb.ccb[p_data->conn.handle - 1]; - p_ccb->handle = 0; - p_ccb->busy = false; - p_ccb->path_len = 0; - p_ccb->path_pos = 0; - if (p_ccb->path) { - osi_free(p_ccb->path); - p_ccb->path = NULL; + if (p_data->conn.handle != 0) { + /* clear ccb */ + p_ccb = &btc_pba_client_cb.ccb[p_data->conn.handle - 1]; + if (p_ccb->path) { + osi_free(p_ccb->path); + } + memset(p_ccb, 0, sizeof(btc_pba_client_ccb_t)); } - memset(p_ccb->bd_addr.address, 0, BD_ADDR_LEN); param.conn_stat.connected = false; bdcpy(param.conn_stat.remote_bda, p_data->conn.bd_addr); param.conn_stat.handle = p_data->conn.handle; diff --git a/components/bt/host/bluedroid/stack/obex/obex_api.c b/components/bt/host/bluedroid/stack/obex/obex_api.c index 0ebf14bf6d..99276a93cf 100644 --- a/components/bt/host/bluedroid/stack/obex/obex_api.c +++ b/components/bt/host/bluedroid/stack/obex/obex_api.c @@ -92,11 +92,11 @@ void OBEX_Deinit(void) if (obex_cb.tl_ops[OBEX_OVER_L2CAP]->deinit != NULL) { obex_cb.tl_ops[OBEX_OVER_L2CAP]->deinit(); } - /* +#if (RFCOMM_INCLUDED == TRUE) if (obex_cb.tl_ops[OBEX_OVER_RFCOMM]->deinit != NULL) { obex_cb.tl_ops[OBEX_OVER_RFCOMM]->deinit(); } - */ +#endif #if (OBEX_DYNAMIC_MEMORY) if (obex_cb_ptr) { osi_free(obex_cb_ptr); diff --git a/tools/ci/check_copyright_config.yaml b/tools/ci/check_copyright_config.yaml index 66352961c2..c7f4a3d4ef 100644 --- a/tools/ci/check_copyright_config.yaml +++ b/tools/ci/check_copyright_config.yaml @@ -240,6 +240,9 @@ ignore: - components/bt/host/bluedroid/ - '!components/bt/host/bluedroid/api/' - '!components/bt/host/bluedroid/btc/' + - '!components/bt/host/bluedroid/bta/pba/' + - '!components/bt/host/bluedroid/stack/goep/' + - '!components/bt/host/bluedroid/stack/obex/' - components/esp_local_ctrl/proto-c/ - components/esp_local_ctrl/python/ - components/protocomm/proto-c/