sysfs itself is now out of module lifespan rules. sysfs callbacks are
guaranteed to stay in memory while running by sysfs node removal waiting
for completion of in-flight operations before returning. In pktcdvd's
case, class_destroy() call in pkt_sysfs_cleanup() will wait for all
in-flight sysfs r/w ops to complete.
So, even while sysfs callbacks are executing, the module beneath can die
but it will stay in memory till all the callbacks return. You need to
test module liveness using try_module_get() (and it can fail) if you
want to grab module reference from sysfs callbacks.
The BUG_ON is detecting valid condition here. If you rmmod pktcdvd
after sysfs write has begun but before __module_get() ran, device node
will be created after the module is killed and scheduled to be unloaded.
Thanks.
--
tejun
-