=== usb_dev.c ================================================================== --- usb_dev.c (revision 262555) +++ usb_dev.c (local) @@ -561,8 +561,8 @@ return (0); } -void -usb_fifo_free(struct usb_fifo *f) +static void +usb_fifo_destroy(struct usb_fifo *f) { uint8_t n; @@ -618,7 +618,16 @@ /* take care of closing the device here, if any */ usb_fifo_close(f, 0); +} +static void +usb_fifo_free(struct usb_fifo *f) +{ + if (f == NULL) { + /* be NULL safe */ + return; + } + cv_destroy(&f->cv_io); cv_destroy(&f->cv_drain); @@ -1867,6 +1876,8 @@ f_rx = usb_fifo_alloc(priv_mtx); if ((f_tx == NULL) || (f_rx == NULL)) { + usb_fifo_destroy(f_tx); + usb_fifo_destroy(f_rx); usb_fifo_free(f_tx); usb_fifo_free(f_rx); return (ENOMEM); @@ -1989,6 +2000,13 @@ if (f_sc == NULL) { return; } + usb_fifo_destroy(f_sc->fp[USB_FIFO_TX]); + usb_fifo_destroy(f_sc->fp[USB_FIFO_RX]); + + usb_destroy_dev(f_sc->dev); + + f_sc->dev = NULL; + usb_fifo_free(f_sc->fp[USB_FIFO_TX]); usb_fifo_free(f_sc->fp[USB_FIFO_RX]); @@ -1995,10 +2013,6 @@ f_sc->fp[USB_FIFO_TX] = NULL; f_sc->fp[USB_FIFO_RX] = NULL; - usb_destroy_dev(f_sc->dev); - - f_sc->dev = NULL; - DPRINTFN(2, "detached %p\n", f_sc); } === usbdi.h ================================================================== --- usbdi.h (revision 262555) +++ usbdi.h (local) @@ -614,6 +614,5 @@ void *usb_fifo_softc(struct usb_fifo *fifo); void usb_fifo_set_close_zlp(struct usb_fifo *, uint8_t); void usb_fifo_set_write_defrag(struct usb_fifo *, uint8_t); -void usb_fifo_free(struct usb_fifo *f); #endif /* _KERNEL */ #endif /* _USB_USBDI_H_ */