Subject: Re: kern/16058: If pcmcia com card insertation fails, kernel panics when card is removed.
To: None <netbsd-bugs@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: netbsd-bugs
Date: 03/25/2002 22:38:44
In article <200203252128.g2PLSGm00960@kaakeli.ssh.fi>,  <kivinen@ssh.fi> wrote:
>
>>Number:         16058
>>Category:       kern
>>Synopsis:       If pcmcia com card insertation fails, kernel panics
>when card is removed.
>>Confidential:   no
>>Severity:       serious
>>Priority:       medium
>>Responsible:    kern-bug-people
>>State:          open
>>Class:          sw-bug
>>Submitter-Id:   net
>>Arrival-Date:   Mon Mar 25 13:30:00 PST 2002
>>Closed-Date:
>>Last-Modified:
>>Originator:     Tero Kivinen
>>Release:        NetBSD 1.5ZC
>>Organization:
>SSH Communications Security
>>Environment:
>System: NetBSD kaakeli.ssh.fi 1.5ZC NetBSD 1.5ZC (KAAKELI) #11: Mon Mar
>25 22:50:11 EET 2002
>root@kaakeli.ssh.fi:/usr/src/sys/arch/i386/compile/KAAKELI i386
>Architecture: i386
>Machine: i386
>>Description:
>

Can you try this one? It is much shorter and does not play with the mi
drivers.

thanks,

christos

Index: com_pcmcia.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/pcmcia/com_pcmcia.c,v
retrieving revision 1.26
diff -u -u -r1.26 com_pcmcia.c
--- com_pcmcia.c	2002/03/10 19:20:50	1.26
+++ com_pcmcia.c	2002/03/25 22:36:18
@@ -217,6 +217,8 @@
 
 	psc->sc_pf = pa->pf;
 
+	psc->sc_io_window = -1;
+
 retry:
 	/* find a cfe we can use */
 
@@ -308,11 +310,13 @@
 	struct com_pcmcia_softc *psc = (struct com_pcmcia_softc *) self;
 	int error;
 
-	if ((error = com_detach(self, flags)) != 0)
-		return error;
+	if (psc->sc_io_window != -1) {
+		if ((error = com_detach(self, flags)) != 0)
+			return error;
 
-	/* Unmap our i/o window. */
-	pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
+		/* Unmap our i/o window. */
+		pcmcia_io_unmap(psc->sc_pf, psc->sc_io_window);
+	}
 
 	/* Free our i/o space. */
 	pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);