aboutsummaryrefslogtreecommitdiff
path: root/hw/sparc64
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2018-08-10 11:40:37 +0100
committerMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2018-08-20 19:18:31 +0100
commit3ac24188eccffe4b6038b47f446c3472897abdf4 (patch)
tree2b3b4127f16c5dae84442d52202ce460675c5f73 /hw/sparc64
parentd0092d90eb546a8bbe9e9120426c189474123797 (diff)
sun4u: ensure kernel_top is always initialised
Valgrind reports that when loading a non-ELF kernel, kernel_top may be used uninitialised when checking for an initrd. Since there are no known non-ELF kernels for SPARC64 then we can simply initialise kernel_top to 0 and then skip the initrd load process if it hasn't been set by load_elf(). Reported-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Diffstat (limited to 'hw/sparc64')
-rw-r--r--hw/sparc64/sun4u.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 74b748497e..d16843b30e 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -139,7 +139,7 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,
unsigned int i;
long kernel_size;
uint8_t *ptr;
- uint64_t kernel_top;
+ uint64_t kernel_top = 0;
linux_boot = (kernel_filename != NULL);
@@ -172,7 +172,7 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,
}
/* load initrd above kernel */
*initrd_size = 0;
- if (initrd_filename) {
+ if (initrd_filename && kernel_top) {
*initrd_addr = TARGET_PAGE_ALIGN(kernel_top);
*initrd_size = load_image_targphys(initrd_filename,