The invariant (me->me_parent == sc) is checked everywhere. Breaking it before removal doesn't seem consistent with the other TAILQ_REMOVE and also is not in the reverse order of TAILQ_INSERT_TAIL.
dash of style while here. --- sys/dev/wscons/wsmux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) In context: https://github.com/blackgnezdo/src/commit/db4503954bc628d2ddac6584126b4781e50fc28f diff --git sys/dev/wscons/wsmux.c sys/dev/wscons/wsmux.c index f92cf46d38d..a6d059252db 100644 --- sys/dev/wscons/wsmux.c +++ sys/dev/wscons/wsmux.c @@ -652,8 +652,8 @@ wsmux_attach_sc(struct wsmux_softc *sc, struct wsevsrc *me) } if (error) { - me->me_parent = NULL; TAILQ_REMOVE(&sc->sc_cld, me, me_next); + me->me_parent = NULL; } DPRINTF(("wsmux_attach_sc: %s(%p) done, error=%d\n", @@ -786,7 +786,7 @@ wsmux_set_display(struct wsmux_softc *sc, struct device *displaydv) } ok = 0; error = 0; - TAILQ_FOREACH(me, &sc->sc_cld,me_next) { + TAILQ_FOREACH(me, &sc->sc_cld, me_next) { #ifdef DIAGNOSTIC if (me->me_parent != sc) { printf("wsmux_set_display: bad child parent %p\n", me); -- 2.19.1
