diff --git a/sys/dev/usb/umidi.c b/sys/dev/usb/umidi.c index 6f8f8397e144..7cfa6ea8e644 100644 --- a/sys/dev/usb/umidi.c +++ b/sys/dev/usb/umidi.c @@ -727,8 +727,14 @@ alloc_all_endpoints(struct umidi_softc *sc) for (i = sc->sc_out_num_endpoints+sc->sc_in_num_endpoints; i > 0; i--) { err = alloc_pipe(ep++); if (err != USBD_NORMAL_COMPLETION) { - for (; ep != sc->sc_endpoints; ep--) + for (; ep != sc->sc_endpoints; ep--) { + KASSERTMSG(ep[-1].pipe != NULL, + "i=%d nin=%d nout=%d", + (int)(ep - 1 - sc->sc_endpoints), + sc->sc_in_num_endpoints, + sc->sc_out_num_endpoints); free_pipe(ep-1); + } kmem_free(sc->sc_endpoints, sc->sc_endpoints_len); sc->sc_endpoints = sc->sc_out_ep = sc->sc_in_ep = NULL; break; @@ -747,8 +753,12 @@ free_all_endpoints(struct umidi_softc *sc) return; } - for (i=0; isc_in_num_endpoints+sc->sc_out_num_endpoints; i++) + for (i=0; isc_in_num_endpoints+sc->sc_out_num_endpoints; i++) { + KASSERTMSG(sc->sc_endpoints[i].pipe != NULL, + "i=%d nin=%d nout=%d", + i, sc->sc_in_num_endpoints, sc->sc_out_num_endpoints); free_pipe(&sc->sc_endpoints[i]); + } kmem_free(sc->sc_endpoints, sc->sc_endpoints_len); sc->sc_endpoints = sc->sc_out_ep = sc->sc_in_ep = NULL; }