mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Aleksander Morgado <aleksander@aleksander.es>
To: barebox@lists.infradead.org
Cc: Aleksander Morgado <aleksander@aleksander.es>
Subject: [PATCH] ratp: only allow bidirectional consoles
Date: Tue,  6 Jun 2017 15:52:10 +0200	[thread overview]
Message-ID: <20170606135210.28846-1-aleksander@aleksander.es> (raw)
In-Reply-To: <20170606053910.bqxqopk7ceirgldp@pengutronix.de>

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>
---
 common/ratp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/ratp.c b/common/ratp.c
index e879e2b3c..7be86d49a 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 {
--
2.12.2

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2017-06-06 13:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01 18:14 [PATCH] console: only bidirectional consoles allow RATP Aleksander Morgado
2017-06-06  5:39 ` Sascha Hauer
2017-06-06 13:52   ` Aleksander Morgado [this message]
2017-06-07  6:03     ` [PATCH] ratp: only allow bidirectional consoles Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170606135210.28846-1-aleksander@aleksander.es \
    --to=aleksander@aleksander.es \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox