The branch main has been updated by mjg:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=176d83eafc5dbeef194ed0e7b1cb24b0ba373fae

commit 176d83eafc5dbeef194ed0e7b1cb24b0ba373fae
Author:     Mateusz Guzik <[email protected]>
AuthorDate: 2023-07-23 13:42:34 +0000
Commit:     Mateusz Guzik <[email protected]>
CommitDate: 2023-07-23 13:44:15 +0000

    vfs: fix up NDFREE_PNBUF usage in vfs_mountroot_shuffle
    
    Noted by:       karels
---
 sys/kern/vfs_mountroot.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c
index 956d29e3f084..b08b2a3200f8 100644
--- a/sys/kern/vfs_mountroot.c
+++ b/sys/kern/vfs_mountroot.c
@@ -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);

Reply via email to