summaryrefslogtreecommitdiff
path: root/libtrivfs
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-08-12 01:05:23 +0000
committerMiles Bader <miles@gnu.org>1995-08-12 01:05:23 +0000
commite958ba53f23ee8e88cc30a7d5838f208c400ec9d (patch)
tree69f6ee8ecbc8e73a30359a3426c70b6d1fa90521 /libtrivfs
parentf4f906598b6438f127478a44f1b14d770a891d15 (diff)
(trivfs_clean_protid): Only call trivfs_protid_destroy_hook hook on CRED if
it was fully initialized.
Diffstat (limited to 'libtrivfs')
-rw-r--r--libtrivfs/protid-clean.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libtrivfs/protid-clean.c b/libtrivfs/protid-clean.c
index cc7726e1..42879c9e 100644
--- a/libtrivfs/protid-clean.c
+++ b/libtrivfs/protid-clean.c
@@ -24,8 +24,11 @@ trivfs_clean_protid (void *arg)
{
struct trivfs_protid *cred = arg;
- if (trivfs_protid_destroy_hook)
+ if (trivfs_protid_destroy_hook && cred->realnode != MACH_PORT_NULL)
+ /* Allow the user to clean up; If the realnode field is null, then CRED
+ wasn't initialized to the point of needing user cleanup. */
(*trivfs_protid_destroy_hook) (cred);
+
mutex_lock (&cred->po->cntl->lock);
if (!--cred->po->refcnt)
{
@@ -35,9 +38,12 @@ trivfs_clean_protid (void *arg)
free (cred->po);
}
mutex_unlock (&cred->po->cntl->lock);
+
free (cred->uids);
free (cred->gids);
- mach_port_deallocate (mach_task_self (), cred->realnode);
+
+ if (cred->realnode != MACH_PORT_NULL)
+ mach_port_deallocate (mach_task_self (), cred->realnode);
}