diff --git a/sys/kern/kern_fp.c b/sys/kern/kern_fp.c --- a/sys/kern/kern_fp.c +++ b/sys/kern/kern_fp.c @@ -161,6 +161,10 @@ } if (flags & FREAD) vmode |= VREAD; + if (td->td_proc == NULL) { + error = EINVAL; + goto bad2; + } if (vmode) { error = VOP_ACCESS(vp, vmode, td->td_proc->p_ucred); if (error) @@ -172,8 +176,7 @@ */ if ((error = falloc(NULL, fpp, NULL)) != 0) goto bad2; - if (td->td_proc) - fsetcred(*fpp, td->td_proc->p_ucred); + fsetcred(*fpp, td->td_proc->p_ucred); error = VOP_OPEN(vp, flags, td->td_proc->p_ucred, fpp);