ref count not decremented in destroy_dev()?

Chuck Tuffli chuck_tuffli at
Thu Jan 20 17:04:43 PST 2005

In my loadable module, the _attach function calls cdevsw_add() and then 
make_dev(). The _detach function calls destroy_dev() and then 
cdevsw_remove() but generates the following dmesg

svd(202)[ffffffff/00000000]: Warning: cdevsw_remove() called while 1 
device ref!

I think the cdevsw_*() calls correctly increment and decrement the 
d_refs variable in struct cdevsw. The part that confuses me is while 
make_dev increments d_refs via a call to hashdev(), there doesn't seem 
to be a corresponding decrement of d_refs in destroy_dev. Does anyone 
know off hand where this should be happening or is my driver 
unregistering incorrectly? Tnx.

Chuck Tuffli
Agilent Technologies

More information about the Kernel mailing list