diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 1c39c424bd7a..34a1bfd64ac2 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -474,7 +474,6 @@ fork1(td, flags, pages, procp) if (pages != 0) vm_thread_new_altkstack(td2, pages); - mtx_lock(&Giant); /* XXX: for VREF() */ PROC_LOCK(p2); PROC_LOCK(p1); @@ -537,11 +536,7 @@ fork1(td, flags, pages, procp) else p2->p_sigparent = SIGCHLD; - /* Bump references to the text vnode (for procfs) */ p2->p_textvp = p1->p_textvp; - if (p2->p_textvp) - VREF(p2->p_textvp); - mtx_unlock(&Giant); /* XXX: for VREF() */ p2->p_fd = fd; p2->p_fdtol = fdtol; @@ -552,6 +547,10 @@ fork1(td, flags, pages, procp) PROC_UNLOCK(p1); PROC_UNLOCK(p2); + /* Bump references to the text vnode (for procfs) */ + if (p2->p_textvp) + vref(p2->p_textvp); + /* * Set up linkage for kernel based threading. */