summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-06-06 15:52:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-06-07 08:02:51 +0200
commit47c7e0672d67f84e3a875ba5250f2db48f3ec802 (patch)
treee7eb9fb45252959020f35cf55b1c46a8d4f66781
parentbda5cb765dd7b1aabf7c7b8d3945d3ead2ed42ad (diff)
downloadbarebox-47c7e0672d67f84e3a875ba5250f2db48f3ec802.tar.gz
ratp: only allow bidirectional consoles
Ignore requests to switch to RATP mode in input-only or output-only consoles. This actually also avoids segfaulting later on: #0 0x0000000000000000 in ?? () #1 0x000000000040b2a4 in console_send (r=<optimized out>, pkt=0x7fffffffd8ec, len=4) at common/ratp.c:102 #2 0x000000000042ab99 in ratp_behaviour_a (pkt=0x7ffff7298780, ri=0x7ffff72766d0) at lib/ratp.c:530 #3 ratp_state_machine (pkt=0x7ffff7298780, ri=0x7ffff72766d0) at lib/ratp.c:1384 #4 ratp_poll (ratp=0x7ffff7277ed8) at lib/ratp.c:1561 #5 0x000000000042b2ab in ratp_establish (ratp=ratp@entry=0x7ffff7277ed8, active=active@entry=false, timeout_ms=timeout_ms@entry=100) at lib/ratp.c:1645 #6 0x000000000040b888 in barebox_ratp (cdev=cdev@entry=0x7ffff7212bd0) at common/ratp.c:470 #7 0x00000000004046c3 in getc_raw () at common/console.c:416 ... Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/ratp.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/common/ratp.c b/common/ratp.c
index e879e2b..7be86d4 100644
--- a/common/ratp.c
+++ b/common/ratp.c
@@ -443,6 +443,9 @@ int barebox_ratp(struct console_device *cdev)
struct ratp_ctx *ctx;
struct ratp *ratp;
+ if (!cdev->getc || !cdev->putc)
+ return -EINVAL;
+
if (ratp_command_ctx) {
ctx = ratp_command_ctx;
} else {