summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2008-08-26 23:21:40 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2008-08-26 23:21:40 +0000
commitbcef90ac5ab304233df23e4ee924cc294d2864c9 (patch)
tree85ca416f07e062cd23050357938eeb837bdb5e07
parent8347a1572d4bca486038444d048001b72820b803 (diff)
2008-08-21 Samuel Thibault <samuel.thibault@ens-lyon.org>
* dir-lookup.c (diskfs_S_dir_lookup): Initialize NEWPI and NEWPO to 0, set back to 0 when they do not need to be referenced any more, dereference them if needed just before exit, after all unlocking.
-rw-r--r--libdiskfs/ChangeLog6
-rw-r--r--libdiskfs/dir-lookup.c24
2 files changed, 19 insertions, 11 deletions
diff --git a/libdiskfs/ChangeLog b/libdiskfs/ChangeLog
index 60c8e90b..e28dd799 100644
--- a/libdiskfs/ChangeLog
+++ b/libdiskfs/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-21 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * dir-lookup.c (diskfs_S_dir_lookup): Initialize NEWPI and NEWPO to
+ 0, set back to 0 when they do not need to be referenced any more,
+ dereference them if needed just before exit, after all unlocking.
+
2008-08-20 Samuel Thibault <samuel.thibault@ens-lyon.org>
* dir-lookup.c (diskfs_S_dir_lookup): Revert 2008-06-06 change, as it
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c
index 15af20e2..7e092908 100644
--- a/libdiskfs/dir-lookup.c
+++ b/libdiskfs/dir-lookup.c
@@ -53,8 +53,8 @@ diskfs_S_dir_lookup (struct protid *dircred,
int mustbedir = 0;
size_t amt;
int type;
- struct protid *newpi;
- struct peropen *newpo;
+ struct protid *newpi = 0;
+ struct peropen *newpo = 0;
if (!dircred)
return EOPNOTSUPP;
@@ -257,8 +257,8 @@ diskfs_S_dir_lookup (struct protid *dircred,
if (! error)
{
error = diskfs_create_protid (newpo, user, &newpi);
- if (error)
- diskfs_release_peropen (newpo);
+ if (! error)
+ newpo = 0;
}
iohelp_free_iouser (user);
@@ -269,6 +269,7 @@ diskfs_S_dir_lookup (struct protid *dircred,
dirport = ports_get_send_right (newpi);
ports_port_deref (newpi);
+ newpi = 0;
if (np != dnp)
mutex_unlock (&dnp->lock);
@@ -460,28 +461,24 @@ diskfs_S_dir_lookup (struct protid *dircred,
dircred->po, &newpo);
if (! error)
- {
- error = diskfs_create_protid (newpo, dircred->user, &newpi);
- if (error)
- diskfs_release_peropen (newpo);
- }
+ error = diskfs_create_protid (newpo, dircred->user, &newpi);
if (! error)
{
+ newpo = 0;
if (flags & O_EXLOCK)
error = fshelp_acquire_lock (&np->userlock, &newpi->po->lock_status,
&np->lock, LOCK_EX);
else if (flags & O_SHLOCK)
error = fshelp_acquire_lock (&np->userlock, &newpi->po->lock_status,
&np->lock, LOCK_SH);
- if (error)
- ports_port_deref (newpi); /* Get rid of NEWPI. */
}
if (! error)
{
*returned_port = ports_get_right (newpi);
ports_port_deref (newpi);
+ newpi = 0;
}
out:
@@ -495,5 +492,10 @@ diskfs_S_dir_lookup (struct protid *dircred,
if (dnp)
diskfs_nput (dnp);
+ if (newpi)
+ ports_port_deref (newpi);
+ if (newpo)
+ diskfs_release_peropen (newpo);
+
return error;
}