null_lookup: restore dvp lock always, not only on success

Caller of VOP_LOOKUP() passes dvp locked and expect it locked on return.
Relock of lower vnode in any case could leave upper vnode reclaimed and
unlocked.

Reported and tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D31310
This commit is contained in:
Konstantin Belousov 2021-07-21 16:19:51 +03:00
parent d5b078163e
commit 4f21442e10

View File

@ -436,11 +436,12 @@ null_lookup(struct vop_lookup_args *ap)
* dvp to be reclaimed due to shared v_vnlock. Check for the
* doomed state and return error.
*/
if ((error == 0 || error == EJUSTRETURN) &&
VN_IS_DOOMED(dvp)) {
error = ENOENT;
if (lvp != NULL)
vput(lvp);
if (VN_IS_DOOMED(dvp)) {
if (error == 0 || error == EJUSTRETURN) {
if (lvp != NULL)
vput(lvp);
error = ENOENT;
}
/*
* If vgone() did reclaimed dvp before curthread