From 0cf3ec7ad8dae5ff969cd849d58de1e1a7bfe6d0 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 15 Oct 2025 12:59:05 -0400 Subject: kern: namei: Return vnode before exiting function If there is a file that is found, we want to return the result before we return from the function, fixes issue with uninitialized vnodes on lookups Signed-off-by: Ian Moffett --- src/sys/os/vfs_namei.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/sys/os/vfs_namei.c b/src/sys/os/vfs_namei.c index e541611..1425c30 100644 --- a/src/sys/os/vfs_namei.c +++ b/src/sys/os/vfs_namei.c @@ -90,14 +90,15 @@ namei(struct nameidata *ndp) lookup.dirvp = mp->vp; lookup.vpp = &vp; - /* If it was found, return */ - error = vops->lookup(&lookup); - if (error == 0) - return 0; - /* Return the result */ - if (ndp->vp_res != NULL) + error = vops->lookup(&lookup); + if (error == 0 && ndp->vp_res != NULL) { *ndp->vp_res = vp; + } + + if (error == 0) { + return 0; + } } printf("namei: f: %s\n", ndp->path); -- cgit v1.2.3