From 520ef2ed66d47bb81a55829a88dda81f62dc95e5 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 20 Jun 2014 13:54:28 +0200 Subject: 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. --- doc/hurd.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/hurd.texi b/doc/hurd.texi index 07ddfb46..8fa6da72 100644 --- a/doc/hurd.texi +++ b/doc/hurd.texi @@ -4431,13 +4431,13 @@ provides. @deftypefun error_t diskfs_create_protid (@w{struct peropen *@var{po}}, @w{struct iouser *@var{user}}, @w{struct protid **@var{cred}}) Create and return a protid for an existing peropen @var{po} in @var{cred}, referring to user @var{user}. The node @code{@var{po}->np} -must be locked. +must be locked. On success, a reference to @var{po} is consumed. @end deftypefun @deftypefun error_t diskfs_start_protid (@w{struct peropen *@var{po}}, @w{struct protid **@var{cred}}) Build and return in @var{cred} a protid which has no user identification, for peropen @var{po}. The node @code{@var{po}->np} must -be locked. +be locked. On success, a reference to @var{po} is consumed. @end deftypefun @deftypefun void diskfs_finish_protid (@w{struct protid *@var{cred}}, @w{struct iouser *@var{user}}) -- cgit v1.2.3