public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] logbuff: Prevent an infinite loop for console output
@ 2010-05-07  0:32 Peter Tyser
  2010-05-07  8:23 ` Detlev Zundel
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Tyser @ 2010-05-07  0:32 UTC (permalink / raw)
  To: u-boot

When using 'logbuff' as stdout and the console loglevel is greater
than a message's loglevel it is supposed to be both logged, and printed
to the console.  The logbuff_printk() function is responsible for both
logging and displaying the message.  However, logbuff_printk()
previously used printf() to print the message to the console.  The
printf() call would eventually end up back in logbuff_printk(), and
an infinite loop would occur which would hang a board.

Using serial_puts() instead of printf() in logbuff_printk() avoids the
recursion and resolves the issue.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Reported-by: Dennis Ruffer <daruffer@gmail.com>
---
 common/cmd_log.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/common/cmd_log.c b/common/cmd_log.c
index e3ebe96..baffeb1 100644
--- a/common/cmd_log.c
+++ b/common/cmd_log.c
@@ -313,9 +313,10 @@ static int logbuff_printk(const char *line)
 				break;
 			}
 		}
-		if (msg_level < console_loglevel) {
-			printf("%s", msg);
-		}
+
+		if (msg_level < console_loglevel)
+			serial_puts(msg);
+
 		if (line_feed)
 			msg_level = -1;
 	}
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-06-08 21:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-07  0:32 [U-Boot] [PATCH] logbuff: Prevent an infinite loop for console output Peter Tyser
2010-05-07  8:23 ` Detlev Zundel
2010-05-07 17:34   ` Peter Tyser
2010-06-08 21:47     ` Wolfgang Denk
2010-06-08 21:58       ` Peter Tyser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox