Commit 13604fb0 authored by Mike Karels's avatar Mike Karels
Browse files

genet: Fix potential crash during attach

As pointed out in the bug, the genet driver (RPi4 Ethernet) was
attaching the interrupts before the data structures were fully
initialized, causing a crash if an interrupt came in during the
attach.  Fix by reordering code blocks.

PR:		256334
Reported by:	< ghuckriede at blackberry.com >
Reviewed by:	< ghuckriede at blackberry.com > (informally)
MFC after:	3 days
parent 9d1cafb3
......@@ -279,21 +279,6 @@ gen_attach(device_t dev)
goto fail;
}
/* Install interrupt handlers */
error = bus_setup_intr(dev, sc->res[_RES_IRQ1],
INTR_TYPE_NET | INTR_MPSAFE, NULL, gen_intr, sc, &sc->ih);
if (error != 0) {
device_printf(dev, "cannot setup interrupt handler1\n");
goto fail;
}
error = bus_setup_intr(dev, sc->res[_RES_IRQ2],
INTR_TYPE_NET | INTR_MPSAFE, NULL, gen_intr2, sc, &sc->ih2);
if (error != 0) {
device_printf(dev, "cannot setup interrupt handler2\n");
goto fail;
}
/* Setup ethernet interface */
sc->ifp = if_alloc(IFT_ETHER);
if_setsoftc(sc->ifp, sc);
......@@ -310,6 +295,21 @@ gen_attach(device_t dev)
IFCAP_HWCSUM_IPV6);
if_setcapenable(sc->ifp, if_getcapabilities(sc->ifp));
/* Install interrupt handlers */
error = bus_setup_intr(dev, sc->res[_RES_IRQ1],
INTR_TYPE_NET | INTR_MPSAFE, NULL, gen_intr, sc, &sc->ih);
if (error != 0) {
device_printf(dev, "cannot setup interrupt handler1\n");
goto fail;
}
error = bus_setup_intr(dev, sc->res[_RES_IRQ2],
INTR_TYPE_NET | INTR_MPSAFE, NULL, gen_intr2, sc, &sc->ih2);
if (error != 0) {
device_printf(dev, "cannot setup interrupt handler2\n");
goto fail;
}
/* Attach MII driver */
mii_flags = 0;
switch (sc->phy_mode)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment