r/kernel • u/AccomplishedAir8352 • Nov 01 '26
How well does linux modules handle resource deallocation?
Hello, I'm a CS undergraduate studying about linux kernel development.
I'm currently on LDD3 book, emphasizing about importance of cleaning up allocated resources on exit.
I assume that this is not likely to be handled properly in some linux modules as removal of modules is not something that is performed on a daily basis.
I have been looking for places to start my contributions and was wondering whether this, identification of memory leaks and applying fixes, could be a valid entry point.
The questions I want to ask is,
- Is this problem considered too trivial?
- Have others been working on it? (maybe there exists some linux group)
- Is this problem commonly found, or gets managed during review process and fixed before getting accepted?
Thank you for your time. Any comments are welcome!
*EDIT Thank you all for your kind responses. They have been very helpful !
View all comments
1
u/paulstelian97 29d ago
Modules not cleaning up memory properly when unloaded is a problem, but not considered a huge one. You’re not supposed to load and unload modules often enough for those leaks to be meaningful, except on your development machine. The kernel marks itself as tainted on any module unload.
That said, it is best to make an effort to clean up everything. You also MUST ensure that whatever you fail to clean up is benign (simple memory leak or resource leak, not an active reference that can lead to invalid pointers to code or data to be used after the module removal; such invalid pointers can lead to kernel oops, panic, or, at worse, misuse of other allocated memory that leads to vulnerabilities). And you MUST ensure that stuff that can allocate memory many times during the module lifetime _does_ have appropriate cleanup.