sbi_dbcn_console_write() loops until all bytes are written and exits early only on an error. When sbi_debug_console_write() returns 0 it stays in the loop forever. A zero return is not an error. Per the SBI specification, the call "may do partial/no writes if the debug console is not able to accept more bytes". OpenSBI can return 0 here. Its semihosting console reports 0 when a host write fails, and SBI passes that number back unchanged. Fix the check to use <= instead of <, so that a zero return also ends the loop. Fixes: c77bf3607a0f ("tty/serial: Add RISC-V SBI debug console based earlycon") Cc: stable@vger.kernel.org Signed-off-by: liutong --- drivers/tty/serial/earlycon-riscv-sbi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c index 0162155f0c83..a8ffee389e15 100644 --- a/drivers/tty/serial/earlycon-riscv-sbi.c +++ b/drivers/tty/serial/earlycon-riscv-sbi.c @@ -29,7 +29,7 @@ static void sbi_dbcn_console_write(struct console *con, while (n) { ret = sbi_debug_console_write(s, n); - if (ret < 0) + if (ret <= 0) break; s += ret; -- 2.34.1