Skip to content

Commit a5121e9

Browse files
yliu80lijinxia
authored andcommitted
dm: uart: add state check of backend tty before uart_closetty
This patch resolves one arcn-dm crash issue when rebooting UOS. The rootcause is that uart releases unopened backend tty. One reproduced case is that the board does not support IOC but IOC feature is enabled in the acrn-dm. After rebooting UOS, crash will happen. NOTE: This issue is not related to IOC, it also can be reproduced with NON-IOC scenario. Just set one invalid PTY to the lpc, then this issue should be reproduced. We need re-visit the whole policy for such scenario in future. Signed-off-by: Yuan Liu <yuan1.liu@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
1 parent fe51acf commit a5121e9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

devicemodel/hw/uart_core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,16 @@ uart_release_backend(struct uart_vdev *uart, const char *opts)
715715
if (opts == NULL)
716716
return;
717717

718+
/*
719+
* By current design, for the invalid PTY parameters, the virtual uarts
720+
* are still expose to UOS but all data be dropped by backend service.
721+
* The uart backend is not setup for this case, so don't try to release
722+
* the uart backend in here.
723+
* TODO: need re-visit the whole policy for such scenario in future.
724+
*/
725+
if (!uart->tty.opened)
726+
return;
727+
718728
uart_closetty(uart);
719729
if (strcmp("stdio", opts) == 0) {
720730
stdio_in_use = false;

0 commit comments

Comments
 (0)