Skip to content

Commit e36381e

Browse files
committed
Fix memory leak in FreeRTOS port timer initialization.
1 parent 2503a86 commit e36381e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/porting/npl/freertos/src/npl_os_freertos.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,9 @@ void
311311
npl_freertos_callout_init(struct ble_npl_callout *co, struct ble_npl_eventq *evq,
312312
ble_npl_event_fn *ev_cb, void *ev_arg)
313313
{
314-
memset(co, 0, sizeof(*co));
315-
co->handle = xTimerCreate("co", 1, pdFALSE, co, os_callout_timer_cb);
314+
if (co->handle == NULL) {
315+
co->handle = xTimerCreate("co", 1, pdFALSE, co, os_callout_timer_cb);
316+
}
316317
co->evq = evq;
317318
ble_npl_event_init(&co->ev, ev_cb, ev_arg);
318319
}
@@ -321,6 +322,7 @@ npl_freertos_callout_deinit(struct ble_npl_callout *co)
321322
{
322323
if (co->handle) {
323324
xTimerDelete(co->handle, portMAX_DELAY);
325+
co->handle = NULL;
324326
}
325327
}
326328

0 commit comments

Comments
 (0)