Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Jun 2021 16:18:23 GMT
From:      Mike Karels <karels@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 13604fb0fd43 - main - genet: Fix potential crash during attach
Message-ID:  <202106201618.15KGINOK079740@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by karels:

URL: https://cgit.FreeBSD.org/src/commit/?id=13604fb0fd43c85e6bb3a0ad6400a684f150bdea

commit 13604fb0fd43c85e6bb3a0ad6400a684f150bdea
Author:     Mike Karels <karels@FreeBSD.org>
AuthorDate: 2021-06-20 16:10:26 +0000
Commit:     Mike Karels <karels@FreeBSD.org>
CommitDate: 2021-06-20 16:17:13 +0000

    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
---
 sys/arm64/broadcom/genet/if_genet.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/sys/arm64/broadcom/genet/if_genet.c b/sys/arm64/broadcom/genet/if_genet.c
index d0fe2b0d5e71..5d70c7075c3a 100644
--- a/sys/arm64/broadcom/genet/if_genet.c
+++ b/sys/arm64/broadcom/genet/if_genet.c
@@ -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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106201618.15KGINOK079740>