From cc618abc5a93f6db285dc66b81ffe942b8e37bf1 Mon Sep 17 00:00:00 2001 From: Onkar Date: Fri, 25 Mar 2022 13:10:40 +0530 Subject: [PATCH] Nimble: Add check for null callout Added change to handle the case when callout deinit / stop is invoked for a already NULL callout --- porting/npl/freertos/src/npl_os_freertos.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/porting/npl/freertos/src/npl_os_freertos.c b/porting/npl/freertos/src/npl_os_freertos.c index f72af604e..4d130c778 100644 --- a/porting/npl/freertos/src/npl_os_freertos.c +++ b/porting/npl/freertos/src/npl_os_freertos.c @@ -746,7 +746,11 @@ IRAM_ATTR npl_freertos_callout_deinit(struct ble_npl_callout *co) { struct ble_npl_callout_freertos *callout = (struct ble_npl_callout_freertos *)co->co; - BLE_LL_ASSERT(callout); + /* Since we dynamically deinit timers, function can be called for NULL timers. Return for such scenarios */ + if (!callout) { + return; + } + BLE_LL_ASSERT(callout->handle); #if CONFIG_BT_NIMBLE_USE_ESP_TIMER @@ -817,6 +821,11 @@ void IRAM_ATTR npl_freertos_callout_stop(struct ble_npl_callout *co) { struct ble_npl_callout_freertos *callout = (struct ble_npl_callout_freertos *)co->co; + + if (!callout) { + return; + } + #if CONFIG_BT_NIMBLE_USE_ESP_TIMER esp_timer_stop(callout->handle); #else