diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-06-20 13:54:28 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-08-31 12:35:10 +0200 |
commit | 520ef2ed66d47bb81a55829a88dda81f62dc95e5 (patch) | |
tree | 8f1f6722409557f40bd3eef097e28923b12d214a /libdiskfs/io-duplicate.c | |
parent | c19a90851170077b99e694262d002a6e22145b49 (diff) |
libdiskfs: fix reference counting of peropen objects
Previously, peropen objects were created with a reference count of
zero. Therefore, if diskfs_create_protid fails, passing such an
object to diskfs_release_peropen would lead to a reference count
underflow.
* libdiskfs/peropen-make.c (diskfs_peropen_make): Initialize reference
count to one.
* libdiskfs/protid-make.c (diskfs_start_protid): And consume this
reference on success. Update comment.
(diskfs_create_protid): Update comment.
* libdiskfs/diskfs.h: Update comments.
* libdiskfs/io-duplicate.c (diskfs_S_io_duplicate): Adjust reference
counting accordingly.
* libdiskfs/io-reauthenticate.c (diskfs_S_io_reauthenticate): Likewise.
* libdiskfs/io-restrict-auth.c (diskfs_S_io_restrict_auth): Likewise.
* doc/hurd.texi (Diskfs Internals): Update accordingly.
Diffstat (limited to 'libdiskfs/io-duplicate.c')
-rw-r--r-- | libdiskfs/io-duplicate.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libdiskfs/io-duplicate.c b/libdiskfs/io-duplicate.c index 45c4df5d..a2e568b7 100644 --- a/libdiskfs/io-duplicate.c +++ b/libdiskfs/io-duplicate.c @@ -32,6 +32,7 @@ diskfs_S_io_duplicate (struct protid *cred, pthread_mutex_lock (&cred->po->np->lock); + refcount_ref (&cred->po->refcnt); err = diskfs_create_protid (cred->po, cred->user, &newpi); if (! err) { @@ -39,6 +40,8 @@ diskfs_S_io_duplicate (struct protid *cred, *portpoly = MACH_MSG_TYPE_MAKE_SEND; ports_port_deref (newpi); } + else + refcount_deref (&cred->po->refcnt); pthread_mutex_unlock (&cred->po->np->lock); |