[coreboot-gerrit] Patch set updated for coreboot: 0197193 libpayload console: Add check for already existing driver

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Wed Mar 18 19:24:43 CET 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8739

-gerrit

commit 01971934af2194b819d7667072a192b577232c12
Author: Furquan Shaikh <furquan at google.com>
Date:   Mon Aug 25 15:06:18 2014 -0700

    libpayload console: Add check for already existing driver
    
    Add support to check if the driver for console_out or console_in is already
    present in the list. If console_init is called twice, then the driver might get
    added twice leading to a loop.
    
    BUG=None
    BRANCH=None
    TEST=With console_init in libpayload and depthcharge both, there are no console
    loops seen anymore
    
    Change-Id: I9103230dfe88added28c51bff33ea4fa1ab034c1
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
    Original-Commit-Id: 6931236ba2cfa71849973fe41cc340b7d70656ad
    Original-Change-Id: If9a927318b850ec59619d92b1da4dddd0aa09cd1
    Original-Signed-off-by: Furquan Shaikh <furquan at google.com>
    Original-Reviewed-on: https://chromium-review.googlesource.com/214072
    Original-Reviewed-by: Aaron Durbin <adurbin at chromium.org>
    Original-Tested-by: Furquan Shaikh <furquan at chromium.org>
    Original-Commit-Queue: Furquan Shaikh <furquan at chromium.org>
---
 payloads/libpayload/libc/console.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/payloads/libpayload/libc/console.c b/payloads/libpayload/libc/console.c
index 827da79..7717daf 100644
--- a/payloads/libpayload/libc/console.c
+++ b/payloads/libpayload/libc/console.c
@@ -35,15 +35,47 @@ struct console_output_driver *console_out;
 struct console_input_driver *console_in;
 static console_input_type last_getchar_input_type;
 
+static int output_driver_exists(struct console_output_driver *out)
+{
+	struct console_output_driver *head = console_out;
+
+	while (head) {
+		if (head == out)
+			return 1;
+		head = head->next;
+	}
+
+	return 0;
+}
+
+static int input_driver_exists(struct console_input_driver *in)
+{
+	struct console_input_driver *head = console_in;
+
+	while (head) {
+		if (head == in)
+			return 1;
+		head = head->next;
+	}
+
+	return 0;
+}
+
 void console_add_output_driver(struct console_output_driver *out)
 {
 	die_if(!out->putchar && !out->write, "Need at least one output func\n");
+	/* Check if this driver was already added to the console list */
+	if (output_driver_exists(out))
+		return;
 	out->next = console_out;
 	console_out = out;
 }
 
 void console_add_input_driver(struct console_input_driver *in)
 {
+	/* Check if this driver was already added to the console list */
+	if (input_driver_exists(in))
+		return;
 	in->next = console_in;
 	console_in = in;
 }



More information about the coreboot-gerrit mailing list