From 3a4bd352d3e4cd682efa5d26896091c3266a689c 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 (cherry picked from commit 3399e0614adbc67350ceac85ac747daef32a0534) --- 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 64afba96e12..c51b81d1a0c 100644 --- a/subsys/shell/backends/shell_telnet.c +++ b/subsys/shell/backends/shell_telnet.c @@ -704,7 +704,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 */ } }