mirror of
https://github.com/opnsense/src.git
synced 2026-03-03 05:41:01 -05:00
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
This commit is contained in:
parent
9d1cafb304
commit
13604fb0fd
1 changed files with 15 additions and 15 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue