Skip to content
Snippets Groups Projects
Commit 77c61260 authored by Beat Küng's avatar Beat Küng
Browse files

px4_task_spawn_cmd: handle case properly when running out of unused taskmap items

parent d3068b43
No related branches found
No related tags found
No related merge requests found
......@@ -233,6 +233,13 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
}
}
if (i >= PX4_MAX_TASKS) {
pthread_attr_destroy(&attr);
pthread_mutex_unlock(&task_mutex);
free(taskdata);
return -ENOSPC;
}
rv = pthread_create(&taskmap[taskid].pid, &attr, &entry_adapter, (void *) taskdata);
if (rv != 0) {
......@@ -261,10 +268,6 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
pthread_attr_destroy(&attr);
pthread_mutex_unlock(&task_mutex);
if (i >= PX4_MAX_TASKS) {
return -ENOSPC;
}
return i;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment