Page MenuHomeFreeBSD

kqueue: don't leak file refs on failure to knote_attach()
ClosedPublic

Authored by kevans on Wed, Apr 8, 8:06 PM.

Details

Summary

We'll subsequently just knote_free() since the knote is barely
constructed, but that bypasses any logic that might release references
on owned files/fops. Defer clearing those until the knote actually owns
them and update the comment to draw the line more clearly.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans requested review of this revision.Wed, Apr 8, 8:06 PM
sys/kern/kern_event.c
1846

What is the reference count the comment talks about?

If it influx state, then it dropped at the end. If not, I really do not understand what is it.

sys/kern/kern_event.c
1846

Reference counts on fp / fops; we should be holding a ref on each until this point, then we transfer ownership over to the knote for them to be taken care of by knote_drop*(). Maybe that exact wording instead: "We transfer ownership of fops/fp to the knote structure and avoid releasing them at the end of this routine now that all future paths will knote_drop(), which takes care of the reference counts we held on fops/fp above."

(Whitespace change below dropped)

sys/kern/kern_event.c
1846

Yes, I think this is much better. Existing text talks about 'reference counts to knote structure', which is simply confusing.

Re-word the comment for clarity

This revision is now accepted and ready to land.Wed, Apr 8, 9:42 PM