diff --git a/devicemodel/hw/uart_core.c b/devicemodel/hw/uart_core.c index 33da09c40..1b67d2979 100644 --- a/devicemodel/hw/uart_core.c +++ b/devicemodel/hw/uart_core.c @@ -715,6 +715,16 @@ uart_release_backend(struct uart_vdev *uart, const char *opts) if (opts == NULL) return; + /* + * By current design, for the invalid PTY parameters, the virtual uarts + * are still expose to UOS but all data be dropped by backend service. + * The uart backend is not setup for this case, so don't try to release + * the uart backend in here. + * TODO: need re-visit the whole policy for such scenario in future. + */ + if (!uart->tty.opened) + return; + uart_closetty(uart); if (strcmp("stdio", opts) == 0) { stdio_in_use = false;