From 3b5a95b0ae6a3cefcd4c080ef5d0f79f8e3b2333 Mon Sep 17 00:00:00 2001 From: Zhi Wei Jian Date: Mon, 2 Mar 2026 10:04:19 +0800 Subject: [PATCH] fix(ble/bluedroid): Fixed read or write failed if SMP is disabled (cherry picked from commit 124f275bdf839b855e6af0cfb9d197f11c9a766c) Co-authored-by: zhiweijian --- components/bt/host/bluedroid/stack/gatt/gatt_api.c | 4 ---- components/bt/host/bluedroid/stack/gatt/gatt_auth.c | 9 +++------ components/bt/host/bluedroid/stack/gatt/gatt_utils.c | 2 -- .../bt/host/bluedroid/stack/gatt/include/gatt_int.h | 2 -- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_api.c b/components/bt/host/bluedroid/stack/gatt/gatt_api.c index a245247d568..dfceedf049d 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_api.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_api.c @@ -1044,13 +1044,11 @@ tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type, tGATT_READ_PARAM default: break; } -#if (SMP_INCLUDED == TRUE) /* start security check */ if (gatt_security_check_start(p_clcb) == FALSE) { status = GATT_NO_RESOURCES; gatt_clcb_dealloc(p_clcb); } -#endif // (SMP_INCLUDED == TRUE) } else { status = GATT_NO_RESOURCES; } @@ -1110,11 +1108,9 @@ tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type, tGATT_VALUE *p_ p_clcb->start_offset = p_write->offset; p->offset = 0; } -#if (SMP_INCLUDED == TRUE) if (gatt_security_check_start(p_clcb) == FALSE) { status = GATT_NO_RESOURCES; } -#endif // (SMP_INCLUDED == TRUE) } else { status = GATT_NO_RESOURCES; } diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_auth.c b/components/bt/host/bluedroid/stack/gatt/gatt_auth.c index a5769a83d71..e205815fed4 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_auth.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_auth.c @@ -129,8 +129,6 @@ void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf) } #endif ///SMP_INCLUDED == TRUE -#if (SMP_INCLUDED == TRUE) - /******************************************************************************* ** ** Function gatt_sec_check_complete @@ -158,6 +156,7 @@ void gatt_sec_check_complete(BOOLEAN sec_check_ok, tGATT_CLCB *p_clcb, UINT8 s } } +#if (SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_enc_cmpl_cback @@ -256,7 +255,7 @@ void gatt_notify_enc_cmpl(BD_ADDR bd_addr) } return; } - +#endif // (SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_set_sec_act @@ -290,7 +289,7 @@ tGATT_SEC_ACTION gatt_get_sec_act(tGATT_TCB *p_tcb) } return sec_act; } -#endif // (SMP_INCLUDED == TRUE) + /******************************************************************************* ** ** Function gatt_determine_sec_act @@ -426,7 +425,6 @@ tGATT_STATUS gatt_get_link_encrypt_status(tGATT_TCB *p_tcb) return encrypt_status ; } -#if (SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_convert_sec_action @@ -524,6 +522,5 @@ BOOLEAN gatt_security_check_start(tGATT_CLCB *p_clcb) return status; } -#endif // (SMP_INCLUDED == TRUE) #endif /* BLE_INCLUDED */ diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_utils.c b/components/bt/host/bluedroid/stack/gatt/gatt_utils.c index e950b67932e..9d38c24292b 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_utils.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_utils.c @@ -2807,7 +2807,6 @@ BOOLEAN gatt_update_auto_connect_dev (tGATT_IF gatt_if, BOOLEAN add, BD_ADDR bd_ } #endif // #if (GATT_BG_CONN_DEV == TRUE) -#if (SMP_INCLUDED == TRUE) /******************************************************************************* ** ** Function gatt_add_pending_new_srv_start @@ -2829,7 +2828,6 @@ tGATT_PENDING_ENC_CLCB *gatt_add_pending_enc_channel_clcb(tGATT_TCB *p_tcb, tGAT } return p_buf; } -#endif // (SMP_INCLUDED == TRUE) char *gatt_uuid_to_str(const tBT_UUID *uuid) { diff --git a/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h b/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h index 933312a46eb..4d5ea687764 100644 --- a/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h +++ b/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h @@ -376,10 +376,8 @@ typedef struct{ }tGATT_PREPARE_WRITE_RECORD; typedef struct { -#if (SMP_INCLUDED == TRUE) fixed_queue_t *pending_enc_clcb; /* pending encryption channel q */ tGATT_SEC_ACTION sec_act; -#endif // (SMP_INCLUDED == TRUE) BD_ADDR peer_bda; tBT_TRANSPORT transport;