From fdc9f4819fcc92272d5c5d75a26f9bb51a6617ff Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Tue, 30 Oct 2007 12:32:47 +0000 Subject: if we cant query the firmware or allocate ccbs then clean up the pci mappings. without this a problem board can cause a panic when the interrupt handler touches unallocated memory. --- sys/dev/pci/arc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'sys') diff --git a/sys/dev/pci/arc.c b/sys/dev/pci/arc.c index 5a18e3d970a..8fa438b9440 100644 --- a/sys/dev/pci/arc.c +++ b/sys/dev/pci/arc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */ +/* $OpenBSD: arc.c,v 1.69 2007/10/30 12:32:46 dlg Exp $ */ /* * Copyright (c) 2006 David Gwynne @@ -469,6 +469,7 @@ void arc_scsi_cmd_done(struct arc_softc *, struct arc_ccb *, /* real stuff for dealing with the hardware */ int arc_map_pci_resources(struct arc_softc *, struct pci_attach_args *); +void arc_unmap_pci_resources(struct arc_softc *); int arc_query_firmware(struct arc_softc *); @@ -525,12 +526,12 @@ arc_attach(struct device *parent, struct device *self, void *aux) if (arc_query_firmware(sc) != 0) { /* error message printed by arc_query_firmware */ - return; + goto unmap_pci; } if (arc_alloc_ccbs(sc) != 0) { /* error message printed by arc_alloc_ccbs */ - return; + goto unmap_pci; } sc->sc_shutdownhook = shutdownhook_establish(arc_shutdown, sc); @@ -571,6 +572,8 @@ arc_attach(struct device *parent, struct device *self, void *aux) #endif return; +unmap_pci: + arc_unmap_pci_resources(sc); } int @@ -906,6 +909,14 @@ unmap: return (1); } +void +arc_unmap_pci_resources(struct arc_softc *sc) +{ + pci_intr_disestablish(sc->sc_pc, sc->sc_ih); + bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); + sc->sc_ios = 0; +} + int arc_query_firmware(struct arc_softc *sc) { -- cgit v1.2.3