Saturday 28 July 2012

Driver unloading .. follow up

After researching the issue of a driver which is unloaded
whilst there are still references to it, and trying various
things, I uncovered a bug in many of the drivers in DTrace.

The following line


.owner = THIS_MODULE,


is the magic which ensures the ref count on the module is
incremented for all opens, and you cannot unload the module whilst
in use.

For various reasons, many drivers didnt have this - probably an issue
with out of date documentation on the older kernels, which predate
this feature.

This link:

http://stackoverflow.com/questions/1741415/linux-kernel-modules-when-to-use-try-module-get-module-put

showed me the error of my ways.

This should stop me accidentally unloading the driver when some
user space process still has a reference to the driver(s).

Post created by CRiSP v11.0.10a-b6436


No comments:

Post a Comment