vfs: fix up NDFREE_PNBUF usage in vfs_mountroot_shuffle

Noted by:	karels
This commit is contained in:
Mateusz Guzik 2023-07-23 13:42:34 +00:00
parent 4d9b2ed34b
commit 176d83eafc

View file

@ -352,13 +352,13 @@ vfs_mountroot_shuffle(struct thread *td, struct mount *mpdevfs)
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, fspath);
error = namei(&nd);
if (error) {
NDFREE_PNBUF(&nd);
fspath = "/mnt";
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE,
fspath);
error = namei(&nd);
}
if (!error) {
NDFREE_PNBUF(&nd);
vp = nd.ni_vp;
error = (vp->v_type == VDIR) ? 0 : ENOTDIR;
if (!error)
@ -376,7 +376,6 @@ vfs_mountroot_shuffle(struct thread *td, struct mount *mpdevfs)
} else
vput(vp);
}
NDFREE_PNBUF(&nd);
if (error)
printf("mountroot: unable to remount previous root "
@ -387,6 +386,7 @@ vfs_mountroot_shuffle(struct thread *td, struct mount *mpdevfs)
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, "/dev");
error = namei(&nd);
if (!error) {
NDFREE_PNBUF(&nd);
vp = nd.ni_vp;
error = (vp->v_type == VDIR) ? 0 : ENOTDIR;
if (!error)
@ -413,7 +413,6 @@ vfs_mountroot_shuffle(struct thread *td, struct mount *mpdevfs)
if (error)
printf("mountroot: unable to remount devfs under /dev "
"(error %d)\n", error);
NDFREE_PNBUF(&nd);
if (mporoot == mpdevfs) {
vfs_unbusy(mpdevfs);