diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-08-01 15:25:53 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-08-01 15:25:53 +0800 |
commit | f9a63d3a640cb30a12598cedc0dd7d8b6fc5b4de (patch) | |
tree | 47d82328de01477ea48098c3c003d2275a526d1c /discover/boot.c | |
parent | 404c07fc44449be7b011d1961280ef9c96e0760d (diff) | |
download | petitboot-f9a63d3a640cb30a12598cedc0dd7d8b6fc5b4de.zip petitboot-f9a63d3a640cb30a12598cedc0dd7d8b6fc5b4de.tar.gz |
discover: fix segfault on failed boot image load
If the boot image fails to load, we end up calling talloc_free on an
unitialised are of stack (boot_task.local_initrd).
Move the initialisers a little earlier, so we always NULL pointers
before potentially freeing.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/boot.c')
-rw-r--r-- | discover/boot.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/discover/boot.c b/discover/boot.c index ed30ef9..e57810d 100644 --- a/discover/boot.c +++ b/discover/boot.c @@ -321,6 +321,9 @@ int boot(void *ctx, struct discover_boot_option *opt, struct boot_command *cmd, result = -1; + boot_task.local_initrd = NULL; + boot_task.local_dtb = NULL; + update_status(status_fn, status_arg, BOOT_STATUS_INFO, "loading kernel"); boot_task.local_image = load_url(NULL, image, &clean_image); @@ -330,7 +333,6 @@ int boot(void *ctx, struct discover_boot_option *opt, struct boot_command *cmd, goto no_load; } - boot_task.local_initrd = NULL; if (initrd) { update_status(status_fn, status_arg, BOOT_STATUS_INFO, "loading initrd"); @@ -342,7 +344,6 @@ int boot(void *ctx, struct discover_boot_option *opt, struct boot_command *cmd, } } - boot_task.local_dtb = NULL; if (dtb) { update_status(status_fn, status_arg, BOOT_STATUS_INFO, "loading device tree"); |