Page MenuHomeFreeBSD

devfs: make destroy_dev() a release barrier for cdevpriv destructors runs
ClosedPublic

Authored by kib on Oct 23 2025, 6:43 PM.
Tags
None
Referenced Files
F162632169: D53303.diff
Wed, Jul 15, 6:51 AM
F162632168: D53303.diff
Wed, Jul 15, 6:51 AM
Unknown Object (File)
Sun, Jul 12, 1:28 AM
Unknown Object (File)
Tue, Jul 7, 4:59 PM
Unknown Object (File)
Tue, Jun 16, 4:35 PM
Unknown Object (File)
May 19 2026, 11:33 AM
Unknown Object (File)
May 18 2026, 11:37 AM
Unknown Object (File)
May 14 2026, 1:00 PM
Subscribers

Details

Summary
Ensure that all destructors for cdevpriv finished running after
destroy_dev() returns to the caller.  Otherwise, since
devfs_destroy_cdevpriv() removes the cdevpriv data from the list, drops
the cdevpriv_mtx, and then starts the destructor, it is possible for
destroy_dev() to return before destructor finished in other thread.

This should allow drivers to safely remove cdev instance data that might
be referenced by cdevpriv data.

Diagnosed by:   kevans

Diff Detail

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