From c82deaf26f5812e73890bbeef942c35f4687e0c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 4 Sep 2017 11:04:17 +0200 Subject: [PATCH] dataman: fix test for return value of px4_task_spawn_cmd And destroy the semaphore if startup fails. Credits for finding this go to @jeonghwan-lee --- src/modules/dataman/dataman.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/dataman/dataman.cpp b/src/modules/dataman/dataman.cpp index daca663cd6..4de8f5d828 100644 --- a/src/modules/dataman/dataman.cpp +++ b/src/modules/dataman/dataman.cpp @@ -1453,8 +1453,9 @@ start() px4_sem_setprotocol(&g_init_sema, SEM_PRIO_NONE); /* start the worker thread with low priority for disk IO */ - if ((task = px4_task_spawn_cmd("dataman", SCHED_DEFAULT, SCHED_PRIORITY_DEFAULT - 10, 1200, task_main, nullptr)) <= 0) { - warn("task start failed"); + if ((task = px4_task_spawn_cmd("dataman", SCHED_DEFAULT, SCHED_PRIORITY_DEFAULT - 10, 1200, task_main, nullptr)) < 0) { + px4_sem_destroy(&g_init_sema); + PX4_ERR("task start failed"); return -1; }