Index: vfs_syscalls.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_syscalls.c,v retrieving revision 1.307 diff -u -r1.307 vfs_syscalls.c --- vfs_syscalls.c 31 Jan 2003 18:57:04 -0000 1.307 +++ vfs_syscalls.c 31 Jan 2003 19:24:51 -0000 @@ -465,6 +465,7 @@ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, pathseg, path, td); if ((error = change_dir(&nd, td)) != 0) return (error); + VOP_UNLOCK(nd.ni_vp, 0, td); NDFREE(&nd, NDF_ONLY_PNBUF); FILEDESC_LOCK(fdp); vp = fdp->fd_cdir; @@ -543,10 +544,11 @@ goto error; #ifdef MAC if ((error = mac_check_vnode_chroot(td->td_ucred, nd.ni_vp))) { - vput(vp); + vput(nd.ni_vp); goto error; } #endif + VOP_UNLOCK(nd.ni_vp, 0, td); FILEDESC_LOCK(fdp); if (chroot_allow_open_directories == 0 || (chroot_allow_open_directories == 1 && fdp->fd_rdir != rootvnode)) { @@ -591,15 +593,13 @@ if (vp->v_type != VDIR) error = ENOTDIR; #ifdef MAC - else if ((error = mac_check_vnode_chdir(td->td_ucred, vp)) != 0) { - } + if (error == 0) + error = mac_check_vnode_chdir(td->td_ucred, vp); #endif - else + if (error == 0) error = VOP_ACCESS(vp, VEXEC, td->td_ucred, td); if (error) vput(vp); - else - VOP_UNLOCK(vp, 0, td); return (error); }