summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2007-01-20 00:36:07 +0000
committerdlg <dlg@openbsd.org>2007-01-20 00:36:07 +0000
commitad72655d20ff9bab108ef304273f7300c364c213 (patch)
tree7967de64b2ddd53d2458529549b1662ae9c54071
parentanother place to check for DT_UNKNOWN for d_type for afs/nfs (diff)
downloadwireguard-openbsd-ad72655d20ff9bab108ef304273f7300c364c213.tar.xz
wireguard-openbsd-ad72655d20ff9bab108ef304273f7300c364c213.zip
move the interrupt establishment till after everything in the softc is
set up and allocated (which happens in a mountroothook). this prevents an early call to the interrupt handler from causing a null deref when trying to look into the unallocated regions. found by mcbride when ciss and bnx were sharing an interrupt. mounting root caused interrupts before the bnx was properly set up. "commit your fix" mcbride@
-rw-r--r--sys/dev/pci/if_bnx.c28
-rw-r--r--sys/dev/pci/if_bnxreg.h4
2 files changed, 16 insertions, 16 deletions
diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c
index f233f0e4d10..1ebfb24cd3a 100644
--- a/sys/dev/pci/if_bnx.c
+++ b/sys/dev/pci/if_bnx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bnx.c,v 1.39 2007/01/19 18:35:50 mcbride Exp $ */
+/* $OpenBSD: if_bnx.c,v 1.40 2007/01/20 00:36:07 dlg Exp $ */
/*-
* Copyright (c) 2006 Broadcom Corporation
@@ -627,7 +627,6 @@ bnx_attach(struct device *parent, struct device *self, void *aux)
u_int32_t val;
pcireg_t memtype;
const char *intrstr = NULL;
- pci_intr_handle_t ih;
sc->bnx_pa = *pa;
@@ -647,12 +646,11 @@ bnx_attach(struct device *parent, struct device *self, void *aux)
return;
}
- if (pci_intr_map(pa, &ih)) {
+ if (pci_intr_map(pa, &sc->bnx_ih)) {
printf(": couldn't map interrupt\n");
goto bnx_attach_fail;
}
-
- intrstr = pci_intr_string(pc, ih);
+ intrstr = pci_intr_string(pc, sc->bnx_ih);
/*
* Configure byte swap and enable indirect register access.
@@ -744,16 +742,6 @@ bnx_attach(struct device *parent, struct device *self, void *aux)
if (val & BNX_PCICFG_MISC_STATUS_32BIT_DET)
sc->bnx_flags |= BNX_PCI_32BIT_FLAG;
- /* Hookup IRQ last. */
- sc->bnx_intrhand = pci_intr_establish(pc, ih, IPL_NET, bnx_intr, sc,
- sc->bnx_dev.dv_xname);
- if (sc->bnx_intrhand == NULL) {
- printf("%s: couldn't establish interrupt", sc->bnx_dev.dv_xname);
- if (intrstr != NULL)
- printf(" at %s", intrstr);
- printf("\n");
- goto bnx_attach_fail;
- }
printf(": %s\n", intrstr);
mountroothook_establish(bnx_attachhook, sc);
@@ -769,6 +757,7 @@ bnx_attachhook(void *xsc)
{
struct bnx_softc *sc = xsc;
struct pci_attach_args *pa = &sc->bnx_pa;
+ pci_chipset_tag_t pc = pa->pa_pc;
struct ifnet *ifp;
u_int32_t val;
int error;
@@ -934,6 +923,15 @@ bnx_attachhook(void *xsc)
/* Get the firmware running so ASF still works. */
bnx_mgmt_init(sc);
+ /* Hookup IRQ last. */
+ sc->bnx_intrhand = pci_intr_establish(pc, sc->bnx_ih, IPL_NET,
+ bnx_intr, sc, sc->bnx_dev.dv_xname);
+ if (sc->bnx_intrhand == NULL) {
+ printf("%s: couldn't establish interrupt\n",
+ sc->bnx_dev.dv_xname);
+ goto bnx_attach_fail;
+ }
+
goto bnx_attach_exit;
bnx_attach_fail:
diff --git a/sys/dev/pci/if_bnxreg.h b/sys/dev/pci/if_bnxreg.h
index 1239b935f7f..958c5febdd8 100644
--- a/sys/dev/pci/if_bnxreg.h
+++ b/sys/dev/pci/if_bnxreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bnxreg.h,v 1.17 2006/11/20 21:26:27 brad Exp $ */
+/* $OpenBSD: if_bnxreg.h,v 1.18 2007/01/20 00:36:08 dlg Exp $ */
/*-
* Copyright (c) 2006 Broadcom Corporation
@@ -4587,7 +4587,9 @@ struct bnx_softc
{
struct device bnx_dev; /* Parent device handle */
struct arpcom arpcom;
+
struct pci_attach_args bnx_pa;
+ pci_intr_handle_t bnx_ih;
struct ifmedia bnx_ifmedia; /* TBI media info */