[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 09/19: trans/crash: fix resource leaks
From: |
Samuel Thibault |
Subject: |
[hurd] 09/19: trans/crash: fix resource leaks |
Date: |
Wed, 10 Aug 2016 00:05:50 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit a8b8ece4ff36fca27492f0a4e925e2f4453ee483
Author: Justus Winter <address@hidden>
Date: Fri Jun 3 16:55:55 2016 +0200
trans/crash: fix resource leaks
Previously, 'task', 'core_file', and 'ctty_id' were not deallocated if
crash was configured to write core files, and 'ctty_id' was leaked if
the crashing task was suspended. This lead to resources not being
released in the kernel, the filesystem, and the terminal subsystem,
and could very well be responsible for making the Debian/Hurd shutdown
hang.
* trans/crash.c (S_crash_dump_task): Properly deallocate 'task',
'core_file', and 'ctty_id'.
---
trans/crash.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/trans/crash.c b/trans/crash.c
index 5db9974..e60ce7e 100644
--- a/trans/crash.c
+++ b/trans/crash.c
@@ -217,7 +217,9 @@ S_crash_dump_task (mach_port_t port,
proc_mark_stop (user_proc, signo, sigcode);
c->task = task;
+ task = MACH_PORT_NULL;
c->core_file = core_file;
+ core_file = MACH_PORT_NULL;
c->core_limit = (off_t) -1; /* XXX should core limit in RPC */
c->signo = signo;
c->sigcode = sigcode;
@@ -251,17 +253,20 @@ S_crash_dump_task (mach_port_t port,
if (!err)
err = proc_mark_exit (user_proc, W_EXITCODE (0, signo), sigcode);
err = task_terminate (task);
- if (!err)
- {
- mach_port_deallocate (mach_task_self (), task);
- mach_port_deallocate (mach_task_self (), core_file);
- mach_port_deallocate (mach_task_self (), ctty_id);
- }
}
}
if (user_proc != MACH_PORT_NULL)
mach_port_deallocate (mach_task_self (), user_proc);
+ if (err == 0 || err = MIG_NO_REPLY)
+ {
+ if (MACH_PORT_VALID (task))
+ mach_port_deallocate (mach_task_self (), task);
+ if (MACH_PORT_VALID (core_file))
+ mach_port_deallocate (mach_task_self (), core_file);
+ if (MACH_PORT_VALID (ctty_id))
+ mach_port_deallocate (mach_task_self (), ctty_id);
+ }
ports_port_deref (cred);
return err;
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] branch upstream updated (04cfa52 -> 02f5c02), Samuel Thibault, 2016/08/09
- [hurd] 18/19: Support MSG_DONTWAIT in pflocal send/recv, Samuel Thibault, 2016/08/09
- [hurd] 19/19: trans/crash: core file name templates, Samuel Thibault, 2016/08/09
- [hurd] 05/19: Revert "drop the deprecated malloc/free hooks in hurd/mach-defpager", Samuel Thibault, 2016/08/09
- [hurd] 09/19: trans/crash: fix resource leaks,
Samuel Thibault <=
- [hurd] 06/19: Complete allocation hooks, Samuel Thibault, 2016/08/09
- [hurd] 12/19: pfinet: fix memory leak, Samuel Thibault, 2016/08/09
- [hurd] 13/19: proc: Fix references to the startup server., Samuel Thibault, 2016/08/09
- [hurd] 02/19: ext2fs: fix pager use-after-free, Samuel Thibault, 2016/08/09
- [hurd] 01/19: libdiskfs: fix error handling, Samuel Thibault, 2016/08/09
- [hurd] 07/19: Fix pipe_send() with no data, Samuel Thibault, 2016/08/09
- [hurd] 11/19: trans/crash: fix blunder, Samuel Thibault, 2016/08/09
- [hurd] 16/19: proc: Fix permission check., Samuel Thibault, 2016/08/09
- [hurd] 14/19: libpager: provide 'pager_create_alloc', Samuel Thibault, 2016/08/09
- [hurd] 03/19: Make <sys/procfs.h> self-contained again, Samuel Thibault, 2016/08/09