commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 48/98: libports: another right leak fix


From: Samuel Thibault
Subject: [hurd] 48/98: libports: another right leak fix
Date: Tue, 14 Jan 2014 02:00:01 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit e5bb7f10e01224d75e55da6e545f779ac0fa73a3
Author: Richard Braun <address@hidden>
Date:   Sat Nov 30 17:20:12 2013 +0100

    libports: another right leak fix
    
    * libports/manage-multithread.c (adjust_priority): Deallocate host
    right before returning.
---
 libports/manage-multithread.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/libports/manage-multithread.c b/libports/manage-multithread.c
index be08030..dcebd09 100644
--- a/libports/manage-multithread.c
+++ b/libports/manage-multithread.c
@@ -53,36 +53,43 @@ adjust_priority (unsigned int totalthreads)
   t = 10 + (((totalthreads - 1) / 100) + 1) * 10;
   thread_switch (MACH_PORT_NULL, SWITCH_OPTION_DEPRESS, t);
 
-  self = pset = pset_priv = MACH_PORT_NULL;
-
   err = get_privileged_ports (&host_priv, NULL);
   if (err)
-    goto out;
+    goto error_host_priv;
 
   self = mach_thread_self ();
   err = thread_get_assignment (self, &pset);
   if (err)
-    goto out;
+    goto error_pset;
 
   err = host_processor_set_priv (host_priv, pset, &pset_priv);
   if (err)
-    goto out;
+    goto error_pset_priv;
 
   err = thread_max_priority (self, pset_priv, 0);
   if (err)
-    goto out;
+    goto error_max_priority;
 
   err = thread_priority (self, THREAD_PRI, 0);
-
-out:
-  if (self != MACH_PORT_NULL)
-    mach_port_deallocate (mach_task_self (), self);
-  if (pset != MACH_PORT_NULL)
-    mach_port_deallocate (mach_task_self (), pset);
-  if (pset_priv != MACH_PORT_NULL)
-    mach_port_deallocate (mach_task_self (), pset_priv);
-
-  if (err && err != EPERM)
+  if (err)
+    goto error_priority;
+
+  mach_port_deallocate (mach_task_self (), pset_priv);
+  mach_port_deallocate (mach_task_self (), pset);
+  mach_port_deallocate (mach_task_self (), self);
+  mach_port_deallocate (mach_task_self (), host_priv);
+  return;
+
+error_priority:
+error_max_priority:
+  mach_port_deallocate (mach_task_self (), pset_priv);
+error_pset_priv:
+  mach_port_deallocate (mach_task_self (), pset);
+error_pset:
+  mach_port_deallocate (mach_task_self (), self);
+  mach_port_deallocate (mach_task_self (), host_priv);
+error_host_priv:
+  if (err != EPERM)
     error (0, err, "unable to adjust libports thread priority");
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]