Index: kern_resource.c =================================================================== --- kern_resource.c (revision 202925) +++ kern_resource.c (working copy) @@ -309,10 +309,11 @@ rtprio_thread(struct thread *td, struct rtprio_thr td1 = td; else td1 = thread_find(p, uap->lwpid); - if (td1 != NULL) - pri_to_rtp(td1, &rtp); - else + if (td1 == NULL) { error = ESRCH; + break; + } + pri_to_rtp(td1, &rtp); PROC_UNLOCK(p); return (copyout(&rtp, uap->rtp, sizeof(struct rtprio))); case RTP_SET: