From 5018a889e1b14a819091ce451b0153644c51ccd4 Mon Sep 17 00:00:00 2001 From: hselasky Date: Sat, 19 Dec 2020 11:00:11 +0000 Subject: [PATCH] Move SYSCTL_ADD_PROC() to unlocked context in if_ure to avoid lock order reversal. MFC after: 1 week Reported by: Mark Millard Sponsored by: Mellanox Technologies // NVIDIA Networking --- sys/dev/usb/net/if_ure.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/dev/usb/net/if_ure.c b/sys/dev/usb/net/if_ure.c index 798c8b1aa09..d552f2c69f5 100644 --- a/sys/dev/usb/net/if_ure.c +++ b/sys/dev/usb/net/if_ure.c @@ -959,8 +959,6 @@ static void ure_attach_post(struct usb_ether *ue) { struct ure_softc *sc = uether_getsc(ue); - struct sysctl_ctx_list *sctx; - struct sysctl_oid *soid; sc->sc_rxstarted = 0; sc->sc_phyno = 0; @@ -988,18 +986,13 @@ ure_attach_post(struct usb_ether *ue) sc->sc_ue.ue_eaddr[0] &= ~0x01; /* unicast */ sc->sc_ue.ue_eaddr[0] |= 0x02; /* locally administered */ } - - sctx = device_get_sysctl_ctx(sc->sc_ue.ue_dev); - soid = device_get_sysctl_tree(sc->sc_ue.ue_dev); - SYSCTL_ADD_PROC(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "chipver", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, - ure_sysctl_chipver, "A", - "Return string with chip version."); } static int ure_attach_post_sub(struct usb_ether *ue) { + struct sysctl_ctx_list *sctx; + struct sysctl_oid *soid; struct ure_softc *sc; struct ifnet *ifp; int error; @@ -1033,6 +1026,13 @@ ure_attach_post_sub(struct usb_ether *ue) BMSR_DEFCAPMASK, sc->sc_phyno, MII_OFFSET_ANY, 0); mtx_unlock(&Giant); + sctx = device_get_sysctl_ctx(sc->sc_ue.ue_dev); + soid = device_get_sysctl_tree(sc->sc_ue.ue_dev); + SYSCTL_ADD_PROC(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "chipver", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0, + ure_sysctl_chipver, "A", + "Return string with chip version."); + return (error); } -- 2.42.0