summaryrefslogtreecommitdiff
path: root/sys/ufs
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2005-07-24 05:43:37 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2005-07-24 05:43:37 +0000
commit73299b7d87d8cd7e18a67a0517f8f13291798f7d (patch)
tree64dcd9601a4662001b48ee647e5f4577c088cae8 /sys/ufs
parenta65817c8d7e9c068e81be82dfb4e99fd4cfb1afa (diff)
Fix a bug introduced in rev 1.58. When relookup() is called with
SAVESTART set in cn_flags, it will add an extra reference to the directory vnode pointer, but only when () succeeds. We were doing vrele() regardless of relookup()'s return value, which caused the reference count to be decremented on error when it shouldn't be. OK pedro@ tedu@
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ufs/ufs_vnops.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index daf2772c627..ab463f59d38 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_vnops.c,v 1.66 2005/07/03 20:14:03 drahn Exp $ */
+/* $OpenBSD: ufs_vnops.c,v 1.67 2005/07/24 05:43:36 millert Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */
/*
@@ -856,13 +856,9 @@ abortit:
if ((fcnp->cn_flags & SAVESTART) == 0)
panic("ufs_rename: lost from startdir");
fcnp->cn_nameiop = DELETE;
- error = relookup(fdvp, &fvp, fcnp);
+ if ((error = relookup(fdvp, &fvp, fcnp)) != 0)
+ return (error); /* relookup did vrele() */
vrele(fdvp);
- if (error)
- return (error);
- if (fvp == NULL) {
- return (ENOENT);
- }
return (VOP_REMOVE(fdvp, fvp, fcnp));
}
@@ -1113,12 +1109,11 @@ abortit:
fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
if ((fcnp->cn_flags & SAVESTART) == 0)
panic("ufs_rename: lost from startdir");
- error = relookup(fdvp, &fvp, fcnp);
- vrele(fdvp);
- if (error) {
+ if ((error = relookup(fdvp, &fvp, fcnp)) != 0) {
vrele(ap->a_fvp);
return (error);
}
+ vrele(fdvp);
if (fvp == NULL) {
/*
* From name has disappeared.