diff --git a/drivers/usbdev/cdcacm.c b/drivers/usbdev/cdcacm.c index 403ad6e230..d3cc8a5ad3 100644 --- a/drivers/usbdev/cdcacm.c +++ b/drivers/usbdev/cdcacm.c @@ -2618,6 +2618,13 @@ static bool cdcuart_txempty(FAR struct uart_dev_s *dev) #endif flags = enter_critical_section(); + + if (dev->disconnected) + { + leave_critical_section(flags); + return true; + } + priv->ispolling = true; EP_POLL(ep); priv->ispolling = false; @@ -3012,6 +3019,10 @@ void cdcacm_uninitialize(FAR struct usbdevclass_driver_s *classdev) char devname[CDCACM_DEVNAME_SIZE]; int ret; + /* Disconnect in case we are connected */ + + cdcacm_disconnect(classdev, priv->usbdev); + #ifndef CONFIG_CDCACM_COMPOSITE usbdev_unregister(&drvr->drvr); #endif