From 5e7d6cfb317d309e6547b55c1eccc9998e90a05c Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 7 Oct 2025 15:38:33 -0400 Subject: kern: filedes: Ignore unitialized vnodes Signed-off-by: Ian Moffett --- src/sys/os/os_filedes.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/sys') diff --git a/src/sys/os/os_filedes.c b/src/sys/os/os_filedes.c index 6fa3e5a..ad1de1f 100644 --- a/src/sys/os/os_filedes.c +++ b/src/sys/os/os_filedes.c @@ -135,19 +135,17 @@ fd_dup(struct proc *procp, int fd) return NULL; } - /* We need the old vnode too */ - if (old->vp == NULL) { - return NULL; - } - /* Allocate an even newer file descriptor */ error = fd_alloc(procp, &new); if (error != 0) { return NULL; } - /* Grab a ref and copy */ - vnode_ref(old->vp); + /* Grab a ref if we can */ + if (old->vp != NULL) { + vnode_ref(old->vp); + } + new->mode = old->mode; new->vp = old->vp; return new; -- cgit v1.2.3