Index: gnu/ext2fs/ext2_vnops.c =================================================================== RCS file: /home/ncvs/src/sys/gnu/ext2fs/ext2_vnops.c,v retrieving revision 1.47 diff -u -r1.47 ext2_vnops.c --- ext2_vnops.c 1999/06/26 02:47:02 1.47 +++ ext2_vnops.c 1999/11/12 03:17:42 @@ -262,14 +262,18 @@ ip->i_rdev = vap->va_rdev; } /* - * Remove inode so that it will be reloaded by VFS_VGET and + * Remove inode, then reload it through VFS_VGET so it is * checked to see if it is an alias of an existing entry in * the inode cache. */ vput(*vpp); (*vpp)->v_type = VNON; vgone(*vpp); - *vpp = 0; + error = VFS_VGET(ap->a_dvp->v_mount, ip->i_ino, vpp); + if (error) { + *vpp = NULL; + return (error); + } return (0); } Index: kern/vfs_syscalls.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_syscalls.c,v retrieving revision 1.140 diff -u -r1.140 vfs_syscalls.c --- vfs_syscalls.c 1999/11/01 04:57:41 1.140 +++ vfs_syscalls.c 1999/11/12 02:24:59 @@ -1142,6 +1142,9 @@ } else { error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); + if (error == 0) { + vput(nd.ni_vp); + } vput(nd.ni_dvp); } } else { @@ -1197,6 +1200,9 @@ vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask; VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE); error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr); + if (error == 0) { + vput(nd.ni_vp); + } vput(nd.ni_dvp); return (error); } Index: kern/vnode_if.src =================================================================== RCS file: /home/ncvs/src/sys/kern/vnode_if.src,v retrieving revision 1.23 diff -u -r1.23 vnode_if.src --- vnode_if.src 1999/09/26 18:10:59 1.23 +++ vnode_if.src 1999/11/12 02:24:59 @@ -109,7 +109,7 @@ # vop_mknod { IN struct vnode *dvp; - OUT WILLRELE struct vnode **vpp; + OUT struct vnode **vpp; IN struct componentname *cnp; IN struct vattr *vap; }; Index: miscfs/union/union_vnops.c =================================================================== RCS file: /home/ncvs/src/sys/miscfs/union/union_vnops.c,v retrieving revision 1.66 diff -u -r1.66 union_vnops.c --- union_vnops.c 1999/10/29 18:09:06 1.66 +++ union_vnops.c 1999/11/12 02:24:59 @@ -705,8 +705,7 @@ if ((dvp = union_lock_upper(dun, cnp->cn_proc)) != NULL) { struct vnode *vp; - error = VOP_MKNOD(dvp, &vp, cnp, ap->a_vap); - /* vp is garbage whether an error occurs or not */ + error = VOP_MKNOD(dvp, ap->a_vpp, cnp, ap->a_vap); union_unlock_upper(dvp, cnp->cn_proc); } return (error); Index: nfs/nfs_serv.c =================================================================== RCS file: /home/ncvs/src/sys/nfs/nfs_serv.c,v retrieving revision 1.86 diff -u -r1.86 nfs_serv.c --- nfs_serv.c 1999/09/29 17:14:58 1.86 +++ nfs_serv.c 1999/11/12 02:24:59 @@ -68,11 +68,11 @@ * error occurs. If no error occurs, the VOP_*() routines only free * the path component if SAVESTART is NOT set. * - * Certain VOP calls (VOP_SYMLINK, VOP_MKNOD), lookup(), and namei() + * VOP_SYMLINK, lookup(), and namei() * may return garbage in various structural fields/return elements * if an error is returned, and may garbage up nd.ni_dvp even if no * error is returned and you did not request LOCKPARENT or WANTPARENT. - * VOP_SYMLINK/VOP_MKNOD return garbage in their return vnode (i.e. not + * VOP_SYMLINK return garbage in its return vnode (i.e. not * something we need to release) even if no error occurs. Our cleanup * code is sensitive to garbage, so we have to carefully clear it out. * @@ -1694,18 +1694,19 @@ vap->va_rdev = rdev; nqsrv_getl(nd.ni_dvp, ND_WRITE); - /* - * VOP_MKNOD returns nd.ni_vp but already releases it, - * so we just NULL the pointer. - */ error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap); - nd.ni_vp = NULL; if (error) { nd.ni_cnd.cn_flags &= ~HASBUF; goto nfsmreply0; } /* + * release vp we do not use + */ + vput(nd.ni_vp); + nd.ni_vp = NULL; + + /* * release dvp prior to lookup */ vput(nd.ni_dvp); @@ -1906,17 +1907,17 @@ goto out; nqsrv_getl(nd.ni_dvp, ND_WRITE); - /* - * VOP_MKNOD does not return a referenced or locked nd.ni_vp, - * but it may set it to (in my view) garbage. - */ error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap); - nd.ni_vp = NULL; - if (error) { nd.ni_cnd.cn_flags &= ~HASBUF; goto out; } + + /* + * release vp we do not use + */ + vput(nd.ni_vp); + nd.ni_vp = NULL; /* * Release dvp prior to lookup Index: ufs/ufs/ufs_vnops.c =================================================================== RCS file: /home/ncvs/src/sys/ufs/ufs/ufs_vnops.c,v retrieving revision 1.125 diff -u -r1.125 ufs_vnops.c --- ufs_vnops.c 1999/11/03 12:05:38 1.125 +++ ufs_vnops.c 1999/11/12 03:17:12 @@ -223,14 +223,18 @@ ip->i_rdev = vap->va_rdev; } /* - * Remove inode so that it will be reloaded by VFS_VGET and + * Remove inode, then reload it through VFS_VGET so it is * checked to see if it is an alias of an existing entry in * the inode cache. */ vput(*vpp); (*vpp)->v_type = VNON; vgone(*vpp); - *vpp = 0; + error = VFS_VGET(ap->a_dvp->v_mount, ip->i_ino, vpp); + if (error) { + *vpp = NULL; + return (error); + } return (0); }