From 6d8bd893546cb3ad05b421f7313e2d5fc44240df Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 11 Oct 2002 21:04:01 +0000 Subject: - Move the 'done1' label down below the unlock of the proc lock and move the locking of the proc lock after the goto to done1 to avoid locking the lock in an error case just so we can turn around and unlock it. - Move the exec_setregs() stuff out from under the proc lock and after the p_args stuff. This allows exec_setregs() to be able to sleep or write things out to userland, etc. which ia64 does. Tested by: peter --- sys/kern/kern_exec.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'sys/kern/kern_exec.c') diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 784ed5c..0e5c94c 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -469,9 +469,9 @@ interpret: PROC_UNLOCK(p); setugidsafety(td); error = fdcheckstd(td); - PROC_LOCK(p); if (error != 0) goto done1; + PROC_LOCK(p); /* * Set the new credentials. */ @@ -543,24 +543,23 @@ interpret: oldargs = p->p_args; p->p_args = NULL; - /* Set values passed into the program in registers. */ - if (p->p_sysent->sv_setregs) - (*p->p_sysent->sv_setregs)(td, imgp->entry_addr, - (u_long)(uintptr_t)stack_base, imgp->ps_strings); - else - exec_setregs(td, imgp->entry_addr, - (u_long)(uintptr_t)stack_base, imgp->ps_strings); - /* Cache arguments if they fit inside our allowance */ if (ps_arg_cache_limit >= i + sizeof(struct pargs)) { bcopy(imgp->stringbase, newargs->ar_args, i); p->p_args = newargs; newargs = NULL; } -done1: PROC_UNLOCK(p); + /* Set values passed into the program in registers. */ + if (p->p_sysent->sv_setregs) + (*p->p_sysent->sv_setregs)(td, imgp->entry_addr, + (u_long)(uintptr_t)stack_base, imgp->ps_strings); + else + exec_setregs(td, imgp->entry_addr, + (u_long)(uintptr_t)stack_base, imgp->ps_strings); +done1: /* * Free any resources malloc'd earlier that we didn't use. */ -- cgit v1.1