PR/16058: Tero Kivinen: Don't attempt to free resources that we failed to

get in the attach phase.
This commit is contained in:
christos 2002-04-13 17:06:53 +00:00
parent db29511727
commit 45c8aefabf

View File

@ -1,4 +1,4 @@
/* $NetBSD: com_pcmcia.c,v 1.27 2002/04/03 00:18:31 christos Exp $ */
/* $NetBSD: com_pcmcia.c,v 1.28 2002/04/13 17:06:53 christos Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: com_pcmcia.c,v 1.27 2002/04/03 00:18:31 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: com_pcmcia.c,v 1.28 2002/04/13 17:06:53 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -310,14 +310,19 @@ com_pcmcia_detach(self, flags)
struct com_pcmcia_softc *psc = (struct com_pcmcia_softc *) self;
int 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. */
if (psc->sc_io_window == -1) {
printf("%s: I/O window not allocated.",
psc->sc_com.sc_dev.dv_xname);
return 0;
}
if ((error = com_detach(self, flags)) != 0)
return error;
/* 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);