|
|
Log in / Subscribe / Register

So do they just leak on module unload?

So do they just leak on module unload?

Posted Oct 23, 2025 7:26 UTC (Thu) by taladar (subscriber, #68407)
Parent article: DebugFS on Rust

> Finally, DebugFS directories have to be manually torn down; they aren't scoped to an individual kernel module.

So what happens on module unload here? Do they just leak if the module doesn't implement cleanup? Can the same module clean them up if it is loaded again? Or a newer version of that module during development where the programmer initially forgets to implement cleanup?

Honestly, this seems like the exact kind of sloppy design common in C that Rust ownership is supposed to make harder to do accidentally.


to post comments

So do they just leak on module unload?

Posted Oct 23, 2025 13:15 UTC (Thu) by daroc (editor, #160859) [Link]

As I understand it, they're tied to a specific directory name, not to a module. So any part of the kernel that asks to unload that directory will unload them. Therefore yes: a newer version of the same module can tear down old entries if it wants to.

On the Rust side of things, the files can persist until the File object is dropped or the scoped directory handle is dropped, depending on which API you use. Unless the driver takes special action to ensure those things leak, they should normally be dropped on module unload. So Rust drivers, at least, don't need to worry about that.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds