From 5f235bdf6f932474cdb17fd8752be47d69db93d2 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Wed, 5 Aug 2026 15:10:01 +0530 Subject: [PATCH] fix(nimble): Add fix to handle service reset during server start --- nimble/host/src/ble_att_svr.c | 5 +++++ nimble/host/src/ble_gatts.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/nimble/host/src/ble_att_svr.c b/nimble/host/src/ble_att_svr.c index 6f0c76e12..1ac8a91dc 100644 --- a/nimble/host/src/ble_att_svr.c +++ b/nimble/host/src/ble_att_svr.c @@ -3542,6 +3542,11 @@ ble_att_svr_free_start_mem(void) return; } #endif + /* Entries are allocated from the pool being torn down here; drop them + * first or the list heads keep dangling pointers across a restart. + */ + ble_att_svr_reset(); + if (ble_att_svr_entry_mem) { nimble_platform_mem_free(ble_att_svr_entry_mem); ble_att_svr_entry_mem = NULL; diff --git a/nimble/host/src/ble_gatts.c b/nimble/host/src/ble_gatts.c index 8d13dbba9..3ca922131 100644 --- a/nimble/host/src/ble_gatts.c +++ b/nimble/host/src/ble_gatts.c @@ -1937,6 +1937,12 @@ ble_gatts_free_mem(void) void ble_gatts_stop(void) { +#if MYNEWT_VAL(BLE_STATIC_TO_DYNAMIC) + if (ble_gatts_static_vars == NULL) { + ble_att_svr_stop(); + return; + } +#endif ble_gatts_free_mem(); ble_hs_max_services = 0;