From f0c0b3a9e6f28a34d6da5edabba1e874fdf8e675 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Wed, 4 May 2011 10:32:28 +0000 Subject: Fix incorrect use of getenv() before relocation A large number of boards incorrectly used getenv() in their board init code running before relocation. In some cases this caused U-Boot to hang when certain environment variables grew too long. Fix the code to use getenv_r(). Signed-off-by: Wolfgang Denk Cc: Stefan Roese Cc: The LEOX team Cc: Michael Schwingen Cc: Georg Schardt Cc: Werner Pfister Cc: Dirk Eibach Cc: Peter De Schrijver Cc: John Zhan Cc: Rishi Bhattacharya Cc: Peter Tyser --- board/etx094/etx094.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'board/etx094') diff --git a/board/etx094/etx094.c b/board/etx094/etx094.c index d6f638a..abefe4a 100644 --- a/board/etx094/etx094.c +++ b/board/etx094/etx094.c @@ -92,8 +92,9 @@ const uint sdram_table[] = { int checkboard (void) { - char *s = getenv ("serial#"); - char *e; + char buf[64]; + int i; + int l = getenv_f("serial#", buf, sizeof(buf)); puts ("Board: "); @@ -103,19 +104,16 @@ int checkboard (void) gd->board_type = 1; /* 1 = 1SDRAM-Device */ #endif - if (!s || strncmp (s, "ETX_", 4)) { + if (l < 0 || strncmp(buf, "ETX_", 4)) { puts ("### No HW ID - assuming ETX_094\n"); read_hw_vers (); return (0); } - for (e = s; *e; ++e) { - if (*e == ' ') + for (i = 0; i < l; ++i) { + if (buf[i] == ' ') break; - } - - for (; s < e; ++s) { - putc (*s); + putc(buf[i]); } putc ('\n'); -- cgit v1.1