summaryrefslogtreecommitdiffstats
path: root/commands/bootm.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2011-11-27 17:51:22 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2011-11-29 20:59:56 +0100
commit351058fa51dbc010c37906b46ecf67a41dbbad8d (patch)
treed7618117468f050f94ce05cbf0079826b0cb6eac /commands/bootm.c
parentec4ee82ca96a6a4867cd3f2e58fed4afd816d14a (diff)
downloadbarebox-351058fa51dbc010c37906b46ecf67a41dbbad8d.tar.gz
barebox-351058fa51dbc010c37906b46ecf67a41dbbad8d.tar.xz
bootm: push relocate_image up to the generic command
All handlers used to just relocate the image without any checks, so we are doomed if we write outside of SDRAM or will overwrite ourselves. Move the relocation up to the generic part where we have a chance of catching these issues. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/bootm.c')
-rw-r--r--commands/bootm.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/commands/bootm.c b/commands/bootm.c
index ff9b18520f..cad7b21261 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -210,6 +210,23 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
puts ("OK\n");
+ /*
+ * FIXME: we do not check at all whether
+ * - we will write the image to sdram
+ * - we overwrite ourselves
+ * - kernel and initrd overlap
+ */
+ ret = relocate_image(data.os, (void *)image_get_load(os_header));
+ if (ret)
+ goto err_out;
+
+ if (data.initrd) {
+ ret = relocate_image(data.initrd,
+ (void *)image_get_load(&data.initrd->header));
+ if (ret)
+ goto err_out;
+ }
+
/* loop through the registered handlers */
list_for_each_entry(handler, &handler_list, list) {
if (image_get_os(os_header) == handler->image_type) {