From: Jan Kiszka <jan.kiszka@domain.hid>
To: Xenomai-core@domain.hid
Subject: [Xenomai-core] [PATCH] Fix tiny memory leaks around rt_task_self()
Date: Fri, 11 Apr 2008 14:51:05 +0200 [thread overview]
Message-ID: <47FF5EB9.9070605@domain.hid> (raw)
Nothing critical, but when using rt_task_self != NULL as a hint if the
caller is Xenomai-mapped or not, this stall malloc can become at least
unpleasant. This is also material for stable.
Jan
---
Index: xenomai/ChangeLog
===================================================================
--- xenomai/ChangeLog (Revision 3698)
+++ xenomai/ChangeLog (Arbeitskopie)
@@ -1,3 +1,8 @@
+2008-04-11 Jan Kiszka <jan.kiszka@domain.hid>
+
+ * src/skins/native/task.c: Fix tiny memory leaks of the task's
+ self-reference key.
+
2008-04-10 Philippe Gerum <rpm@xenomai.org>
* src/skins/*: Force minimum stack size to 32k, in order to work
Index: xenomai/src/skins/native/task.c
===================================================================
--- xenomai/src/skins/native/task.c (Revision 3698)
+++ xenomai/src/skins/native/task.c (Arbeitskopie)
@@ -52,6 +52,11 @@ static void rt_task_sigharden(int sig)
XENOMAI_SYSCALL1(__xn_sys_migrate, XENOMAI_XENO_DOMAIN);
}
+static void rt_task_cleanup_tskey(void *arg)
+{
+ free(pthread_getspecific(__native_tskey));
+}
+
static void *rt_task_trampoline(void *cookie)
{
struct rt_task_iargs *iargs = (struct rt_task_iargs *)cookie;
@@ -92,8 +97,11 @@ static void *rt_task_trampoline(void *co
err = XENOMAI_SYSCALL2(__xn_sys_barrier, &entry, &cookie);
while (err == -EINTR);
- if (!err)
+ if (!err) {
+ pthread_cleanup_push(rt_task_cleanup_tskey, NULL);
entry(cookie);
+ pthread_cleanup_pop(1);
+ }
fail:
@@ -294,8 +302,10 @@ RT_TASK *rt_task_self(void)
self = (RT_TASK *)malloc(sizeof(*self));
if (!self ||
- XENOMAI_SKINCALL1(__native_muxid, __native_task_self, self) != 0)
+ XENOMAI_SKINCALL1(__native_muxid, __native_task_self, self) != 0) {
+ free(self);
return NULL;
+ }
pthread_setspecific(__native_tskey, self);
next reply other threads:[~2008-04-11 12:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-11 12:51 Jan Kiszka [this message]
2008-04-11 13:27 ` [Xenomai-core] [PATCH] Fix tiny memory leaks around rt_task_self() Gilles Chanteperdrix
2008-04-11 14:06 ` Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47FF5EB9.9070605@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=Xenomai-core@domain.hid \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.