Skip to content

Commit 4d4b005

Browse files
committed
[Bugfix] Memory leak in init/deinit cycle with esp32c6/c5/c2/h2
1 parent 06a69d2 commit 4d4b005

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/nimble/porting/nimble/src/nimble_port.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ esp_err_t esp_nimble_init(void)
104104
na_hci_transport_init(HCI_TRANSPORT_VHCI);
105105
int na_npl_freertos_mempool_init(void);
106106
na_npl_freertos_mempool_init();
107+
#ifdef CONFIG_BT_BLUEDROID_ENABLED
107108
ble_npl_eventq_init(&g_eventq_dflt);
109+
#endif
108110
#endif
109111

110112
ble_transport_ll_init();
@@ -140,6 +142,15 @@ esp_err_t esp_nimble_deinit(void)
140142
ble_hs_deinit();
141143

142144
ble_transport_ll_deinit();
145+
146+
#if CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT
147+
na_hci_transport_deinit();
148+
void na_npl_freertos_mempool_deinit(void);
149+
na_npl_freertos_mempool_deinit();
150+
#ifdef CONFIG_BT_BLUEDROID_ENABLED
151+
ble_npl_eventq_deinit(&g_eventq_dflt);
152+
#endif
153+
#endif
143154
return ESP_OK;
144155
}
145156

@@ -228,10 +239,6 @@ nimble_port_deinit(void)
228239
return ret;
229240
}
230241

231-
#if CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT
232-
na_hci_transport_deinit();
233-
#endif
234-
235242
ret = esp_bt_controller_deinit();
236243
if(ret != ESP_OK) {
237244
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "controller deinit failed\n");

0 commit comments

Comments
 (0)