Keith Owens wrote:
> Other calls to module functions do not run under the big kernel lock.
> Instead they are meant to call open() first which bumps the reference
The problem with the net drivers is that they are "opened" within the
module constructor, "closed" with the module destructor and their "open"
and "close" methods don't (can't) manipulate the refcounts.
You see, netdevice.open() is a misnomer. It simply switches an
existing, already-open netdevice from 'down' to 'up'. It should be
called 'start' (cf netdevice.stop).
It's register_netdevice() which registers a device with the kernel and
makes all its entry points available for use. register_netdevice is
called from within module_init().
Seen in this light, incrementing the refcount within netdevice.open() is
kinda arbitrary. All the other netdevice methods should also increment
the refcount (yes, racy).
rm /sbin/rmmod. There. Fixed.