Skip to content

Commit cdd0310

Browse files
keviniorChromeos LUCI
authored and
Chromeos LUCI
committed
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 (cherry picked from commit 3399e06) Original-Link: zephyrproject-rtos/zephyr#67637 Original-Signed-off-by: Kevin ORourke <[email protected]> GitOrigin-RevId: 3399e06 Cr-Build-Id: 8734380568354140561 Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8734380568354140561 Copybot-Job-Name: zephyr-main-copybot-downstream Change-Id: I4f40ac58f0ee844e4dff85196727fd3b4f56939d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5925541 Commit-Queue: Jeremy Bettis <[email protected]> Tested-by: ChromeOS Prod (Robot) <[email protected]> Tested-by: Jeremy Bettis <[email protected]> Reviewed-by: Jeremy Bettis <[email protected]>
1 parent 7efb067 commit cdd0310

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

subsys/shell/backends/shell_telnet.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,12 @@ static int telnet_write(const struct shell_transport *transport,
708708
err = telnet_send(true);
709709
if (err != 0) {
710710
*cnt = length;
711-
return err;
711+
if ((err == -ENOTCONN) || (err == -ENETDOWN)) {
712+
LOG_ERR("Network disconnected, shutting down");
713+
} else {
714+
LOG_ERR("Error %d, shutting down", err);
715+
}
716+
return 0; /* Return 0 to not trigger ASSERT in shell_ops.c */
712717
}
713718
}
714719

0 commit comments

Comments
 (0)