Clean up vnode handling on return from chroot() in certain error

cases: we might multiply vrele() a vnode when certain classes of
failures occur.  This appears to stem from earlier Giant/file
descriptor lock pushdown and restructuring.

Submitted by:	maxim
This commit is contained in:
rwatson 2003-01-31 18:57:04 +00:00
parent bbd6f8d1ff
commit 21c1d8195b
2 changed files with 8 additions and 4 deletions

View File

@ -542,8 +542,10 @@ chroot(td, uap)
if ((error = change_dir(&nd, td)) != 0)
goto error;
#ifdef MAC
if ((error = mac_check_vnode_chroot(td->td_ucred, nd.ni_vp)))
if ((error = mac_check_vnode_chroot(td->td_ucred, nd.ni_vp))) {
vput(vp);
goto error;
}
#endif
FILEDESC_LOCK(fdp);
if (chroot_allow_open_directories == 0 ||
@ -567,7 +569,7 @@ error_unlock:
FILEDESC_UNLOCK(fdp);
error:
mtx_unlock(&Giant);
NDFREE(&nd, 0);
NDFREE(&nd, NDF_ONLY_PNBUF);
return (error);
}

View File

@ -542,8 +542,10 @@ chroot(td, uap)
if ((error = change_dir(&nd, td)) != 0)
goto error;
#ifdef MAC
if ((error = mac_check_vnode_chroot(td->td_ucred, nd.ni_vp)))
if ((error = mac_check_vnode_chroot(td->td_ucred, nd.ni_vp))) {
vput(vp);
goto error;
}
#endif
FILEDESC_LOCK(fdp);
if (chroot_allow_open_directories == 0 ||
@ -567,7 +569,7 @@ error_unlock:
FILEDESC_UNLOCK(fdp);
error:
mtx_unlock(&Giant);
NDFREE(&nd, 0);
NDFREE(&nd, NDF_ONLY_PNBUF);
return (error);
}