public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Prevent a U-Boot crash on Wandboard
@ 2013-09-23  1:21 Steven Falco
  2013-09-23 11:40 ` Otavio Salvador
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Steven Falco @ 2013-09-23  1:21 UTC (permalink / raw)
  To: u-boot

Prevent a crash when PXE boot calls do_bootm with a vmlinuz formatted image.
In this case, there will be a null cmdtp pointer, and we must not dereference
it.

Signed-off-by: Steven A. Falco <stevenfalco@gmail.com>

---

In file cmd_pxe.c around line 687 is a call:

do_bootm(NULL, 0, bootm_argc, bootm_argv);

Notice that the first argument is NULL.  Therefore, the cmdtp
pointer will always be NULL when using the pxe boot mechanism.

do_bootm() eventually calls boot_get_kernel(), still with cmdtp == NULL.
In the Wandboard case, the vmlinuz binary is not "legacy format", nor is
it "fit format", so U-Boot attempts to print:

printf("Wrong Image Format for %s command\n", cmdtp->name);

That is doomed to fail, because cmdtp is NULL.  The following patch corrects
the problem; the command name will be printed only if the pointer is valid.

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 349f165..2249682 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -985,7 +985,10 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
  		break;
  #endif
  	default:
-		printf("Wrong Image Format for %s command\n", cmdtp->name);
+		if (cmdtp)
+			printf("Wrong Image Format for %s command\n", cmdtp->name);
+		else
+			printf("Wrong Image Format for command\n");
  		bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO);
  		return NULL;
  	}

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

end of thread, other threads:[~2013-09-23 23:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-23  1:21 [U-Boot] [PATCH] Prevent a U-Boot crash on Wandboard Steven Falco
2013-09-23 11:40 ` Otavio Salvador
2013-09-23 18:47   ` Wolfgang Denk
2013-09-23 16:11 ` Albert ARIBAUD
2013-09-23 16:21   ` Fabio Estevam
2013-09-23 18:18     ` Tom Rini
2013-09-23 18:50     ` Wolfgang Denk
2013-09-23 19:17       ` Tom Rini
2013-09-23 19:45         ` Tom Rini
2013-09-23 20:44           ` Wolfgang Denk
2013-09-23 23:23             ` Steven Falco
2013-09-23 20:43         ` Wolfgang Denk
2013-09-23 18:45 ` Wolfgang Denk

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