From 4f7ae6eab166d61b70ec21b6a701a8e5c85f2088 Mon Sep 17 00:00:00 2001 From: Kevin ORourke Date: Wed, 25 Sep 2024 08:55:12 +0200 Subject: [PATCH] shell: backend: telnet: Don't assert if connection closed The code in shell_ops.c that calls telnet_write will assert if it returns non-zero. For a telnet shell it's normal that the network might disconnect unexepectedly, so that should not trigger an assert. Fixes #67637 Link: https://github.com/zephyrproject-rtos/zephyr/issues/67637 Signed-off-by: Kevin ORourke --- subsys/shell/backends/shell_telnet.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/subsys/shell/backends/shell_telnet.c b/subsys/shell/backends/shell_telnet.c index f6b340e3ab0b..862c7d80ac8b 100644 --- a/subsys/shell/backends/shell_telnet.c +++ b/subsys/shell/backends/shell_telnet.c @@ -708,7 +708,12 @@ static int telnet_write(const struct shell_transport *transport, err = telnet_send(true); if (err != 0) { *cnt = length; - return err; + if ((err == -ENOTCONN) || (err == -ENETDOWN)) { + LOG_ERR("Network disconnected, shutting down"); + } else { + LOG_ERR("Error %d, shutting down", err); + } + return 0; /* Return 0 to not trigger ASSERT in shell_ops.c */ } }