Don't assume rt_task_delete is only called for in-kernel users, it may
be triggered via auto-cleanup also on user space objects. So check for
the creator and release the fastlock to the correct heap.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>
---

 ksrc/skins/native/mutex.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ksrc/skins/native/mutex.c b/ksrc/skins/native/mutex.c
index 20eb484..6cf7eb1 100644
--- a/ksrc/skins/native/mutex.c
+++ b/ksrc/skins/native/mutex.c
@@ -47,6 +47,7 @@
 #include <nucleus/pod.h>
 #include <nucleus/registry.h>
 #include <nucleus/heap.h>
+#include <nucleus/sys_ppd.h>
 #include <native/task.h>
 #include <native/mutex.h>
 
@@ -316,8 +317,17 @@ int rt_mutex_delete(RT_MUTEX *mutex)
        err = rt_mutex_delete_inner(mutex);
 
 #ifdef CONFIG_XENO_FASTSYNCH
-       if (!err)
-               xnfree(mutex->synch_base.fastlock);
+       if (!err) {
+#ifdef CONFIG_XENO_OPT_PERVASIVE
+               if (mutex->cpid) {
+                       int global = xnsynch_test_flags(&mutex->synch_base,
+                                                       RT_MUTEX_EXPORTED);
+                       xnheap_free(&xnsys_ppd_get(global)->sem_heap,
+                                   mutex->synch_base.fastlock);
+               } else
+#endif /* CONFIG_XENO_OPT_PERVASIVE */
+                       xnfree(mutex->synch_base.fastlock);
+       }
 #endif /* CONFIG_XENO_FASTSYNCH */
 
        return err;


_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to