linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crash in pcmcia_access_configuration_register
@ 2003-03-04  4:23 Pavel Roskin
  0 siblings, 0 replies; only message in thread
From: Pavel Roskin @ 2003-03-04  4:23 UTC (permalink / raw)
  To: linux-kernel

Hello!

As promised, here's the patch to fix an oops in the kernel PCMCIA driver.
The patch should be applied both to 2.4 and 2.5 series.

How to reproduce the bug:

1) Compile and install HostAP (http://hostap.epitest.fi/) - any recent
version (CVS version is OK).

2) Insert a card supported by HostAP.

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

Explanation:

While doing a reset, HostAP used AccessConfigurationRegister request to
preserve the value of the configuration register.  The reset is triggered
by the removal of the card.

I do believe that HostAP can be improved to avoid reset if the socket
configuration has been released.  Nevertheless, oops is not a reputable
behavior when the driver merely requests a configuration register.

The pcmcia-cs driver already has a slightly different protection, but the
following patch is simpler and addresses the problem right before it
happens.

====================================
--- drivers/pcmcia/cs.c
+++ drivers/pcmcia/cs.c
@@ -882,6 +882,10 @@ int pcmcia_access_configuration_register
 	c = &s->config[reg->Function];
     } else
 	c = CONFIG(handle);
+
+    if (c == NULL)
+	return CS_NO_CARD;
+
     if (!(c->state & CONFIG_LOCKED))
 	return CS_CONFIGURATION_LOCKED;

====================================

-- 
Regards,
Pavel Roskin

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-03-04  4:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-04  4:23 [PATCH] crash in pcmcia_access_configuration_register Pavel Roskin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).