diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 3b220c38e0b3..9dabf7c82503 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -2534,10 +2534,8 @@ sysctl_kern_proc_kstack(SYSCTL_HANDLER_ARGS) st = stack_create(); lwpidarray = NULL; - numthreads = 0; PROC_LOCK(p); -repeat: - if (numthreads < p->p_numthreads) { + do { if (lwpidarray != NULL) { free(lwpidarray, M_TEMP); lwpidarray = NULL; @@ -2547,9 +2545,7 @@ sysctl_kern_proc_kstack(SYSCTL_HANDLER_ARGS) lwpidarray = malloc(sizeof(*lwpidarray) * numthreads, M_TEMP, M_WAITOK | M_ZERO); PROC_LOCK(p); - goto repeat; - } - i = 0; + } while (numthreads < p->p_numthreads); /* * XXXRW: During the below loop, execve(2) and countless other sorts @@ -2560,6 +2556,7 @@ sysctl_kern_proc_kstack(SYSCTL_HANDLER_ARGS) * have changed, in which case the right to extract debug info might * no longer be assured. */ + i = 0; FOREACH_THREAD_IN_PROC(p, td) { KASSERT(i < numthreads, ("sysctl_kern_proc_kstack: numthreads"));