negative module count in /proc/modules

Brad Davidson kiloman
Wed Sep 24 14:34:19 PDT 2003

Here's a fun one. I got the modules usage count to go negative.
Steps to recreate:

Install HostAP (I'm using the latest CVS tarball). Bind the modules to 
your PCMCIA card in the PCMCIA-CS config file, and insert the card. 
After the card is configured, physically eject it from the cardslot.

The following appears in the kernel debug log:
wlan0: Interupt, but SWSUPPORT0 does not match: FFFF != 8A32 - card removed?
wlan0: prism2_interupt: ev=0xffff
ti113x: Routing card interupts to PCI
wlan0: scheduled card reset
hostap_cs: wlan0: resetting card
wlan0: card already removed or not configured during shutdown
wlan0: hfa384x_cmd - timeout - reg=0xfff
hostap_cs: first command failed - is the card compatible?
prism2_tx_timeout: wake up queue
wlan0: card allready removed or not configured during shutdown
hostap_cs: Netdevice wlan0 unregistered

If the same thing is done again, the usage count will drop to -2, and so on.

If, when the usage count is -1, you insert the card, the device will be 
usable, but the usage count will be 0. If you run modprobe -r hostap_cs 
to remove the module, the system will hang (or possibly oops, on other 

Everything works just dandy if I use 'cardctl eject' before removing the 

Seems to me that the module is getting unloaded twice - once when the 
driver is called in interupt context because the card was ejected, and 
another when the waiting tx request wakes up, and notices that the card 
is gone. Locking problem?

This is all on a Pismo G3 with PCMCIA-CS 3.2.5, using the kernel PCMCIA 

If I have some time I might go poke at the driver myself, but I'll warn 
everybody that I'm only up to chapter 4 in "programing linux device 
drivers", so I'm not expecting any particular results at all :)


More information about the Hostap mailing list