From 4cb0c0561c4529f50a2ffdd9ac9987fc5ec2a1fd Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Wed, 24 Jul 2019 12:17:54 +0200 Subject: [PATCH] nimble/host: Fix initialization order Transport should be configured after default queue is set. Callbacks set by host handle data by putting them on queue and use event queue to notify host. If queue is not set (which can happen if transport sends data immediately after callbacks are registered), we'll have crash. --- nimble/host/src/ble_hs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nimble/host/src/ble_hs.c b/nimble/host/src/ble_hs.c index c311847c3..c269636ba 100644 --- a/nimble/host/src/ble_hs.c +++ b/nimble/host/src/ble_hs.c @@ -781,15 +781,15 @@ ble_hs_init(void) ble_hs_dbg_mutex_locked = 0; #endif - /* Configure the HCI transport to communicate with a host. */ - ble_hci_trans_cfg_hs(ble_hs_hci_rx_evt, NULL, ble_hs_rx_data, NULL); - #ifdef MYNEWT ble_hs_evq_set((struct ble_npl_eventq *)os_eventq_dflt_get()); #else ble_hs_evq_set(nimble_port_get_dflt_eventq()); #endif + /* Configure the HCI transport to communicate with a host. */ + ble_hci_trans_cfg_hs(ble_hs_hci_rx_evt, NULL, ble_hs_rx_data, NULL); + #if BLE_MONITOR rc = ble_monitor_init(); SYSINIT_PANIC_ASSERT(rc == 0);