Commit 0d57f9bd authored by Jan Kiszka's avatar Jan Kiszka Committed by Philippe Gerum
Browse files

cobalt/posix: Harden cobalt_thread_shadow against invalid requests

If the caller has already a Xenomai shadow, we will crash rather than
failing gracefully. The reason is that pthread_discard expects secondary
mode - which may not be the case if the caller is already able to
migrate. So check early and avoid that we can run into this trap.
Signed-off-by: Jan Kiszka's avatarJan Kiszka <>
parent bc40525b
......@@ -625,6 +625,9 @@ cobalt_thread_shadow(struct task_struct *p,
struct sched_param_ex param_ex;
int ret;
if (xnthread_current())
return ERR_PTR(-EBUSY);
param_ex.sched_priority = 0;
trace_cobalt_pthread_create(hkey->u_pth, SCHED_NORMAL, &param_ex);
ret = pthread_create(&thread, SCHED_NORMAL, &param_ex, p);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment