kernel - MPSAFE work - fix bugs in recent MPSAFE work.
[dragonfly.git] / sys / kern / kern_event.c
index 72eaecf..defe052 100644 (file)
@@ -198,15 +198,20 @@ filt_procattach(struct knote *kn)
        int immediate;
 
        immediate = 0;
+       lwkt_gettoken(&proc_token);
        p = pfind(kn->kn_id);
        if (p == NULL && (kn->kn_sfflags & NOTE_EXIT)) {
                p = zpfind(kn->kn_id);
                immediate = 1;
        }
-       if (p == NULL)
+       if (p == NULL) {
+               lwkt_reltoken(&proc_token);
                return (ESRCH);
-       if (!PRISON_CHECK(curthread->td_ucred, p->p_ucred))
+       }
+       if (!PRISON_CHECK(curthread->td_ucred, p->p_ucred)) {
+               lwkt_reltoken(&proc_token);
                return (EACCES);
+       }
 
        kn->kn_ptr.p_proc = p;
        kn->kn_flags |= EV_CLEAR;               /* automatically set */
@@ -230,6 +235,7 @@ filt_procattach(struct knote *kn)
         */
        if (immediate && filt_proc(kn, NOTE_EXIT))
                KNOTE_ACTIVATE(kn);
+       lwkt_reltoken(&proc_token);
 
        return (0);
 }