Fix for crash on card removal

Pavel Roskin proski at gnu.org
Mon Mar 3 23:47:20 EST 2003


Hello!

Using AccessConfigurationRegister is unsafe is the card has been removed.
There is a long-standing bug in the PCMCIA drivers that causes a kernel
oops.  This bug was been patched in pcmcia-cs, but it's still present in
the kernel PCMCIA drivers (both 2.4.x and 2.5.x).

I have just sent a patch to LKML, but I think it's a good idea to put
protection into the HostAP driver itself, especially because it's
reasonable and simple.

How to reproduce the bug:

1) Compile kernel with PCMCIA support.

2) Compile and install HostAP.

3) Insert a card supported by HostAP.

4) Remove (physically) the card.  The kernel oopses.

It happens because the driver (cs.c) doesn't check the state of the
socket.  Fortunately, we have function prism2_pccard_card_present() that
does exactly the right thing.

A similar precaution can be found in the Orinoco driver 0.11b (further
versions don't use COR reset).

The patch is against CVS HostAP, of course:

===========================
--- driver/modules/hostap_cs.c
+++ driver/modules/hostap_cs.c
@@ -217,6 +217,9 @@ static void prism2_pccard_cor_sreset(loc
 	int res;
 	conf_reg_t reg;

+	if (!prism2_pccard_card_present(local))
+		return;
+
 	reg.Function = 0;
 	reg.Action = CS_READ;
 	reg.Offset = CISREG_COR;
===========================

The patch has been heavily tested (I removed the card at least 20 times).

-- 
Regards,
Pavel Roskin



More information about the HostAP mailing list