From: "Shreya Shrivastava" <pink89@sigaint.org>
To: qemu-devel@nongnu.org
Cc: stefanha@gmail.com
Subject: [Qemu-devel] [PATCH 2/4] Add error checking for load_image_targphys.
Date: Sun, 16 Oct 2016 00:48:24 -0000 [thread overview]
Message-ID: <a9716f112de7394c88600eb4588c15d7.webmail@localhost> (raw)
Add checks for negative return value to uses of load_image_targphys.
Signed-off-by: Shreya Shrivastava <pink89@sigaint.org>
---
hw/arm/nseries.c | 9 +++++++--
hw/lm32/milkymist.c | 19 +++++++++++++++----
hw/ppc/virtex_ml507.c | 5 +++++
3 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index c86cf80..e0b0ae5 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -1306,6 +1306,7 @@ static int n810_atag_setup(const struct
arm_boot_info *info, void *p)
static void n8x0_init(MachineState *machine,
struct arm_boot_info *binfo, int model)
{
+ int rom_size;
MemoryRegion *sysmem = get_system_memory();
struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s));
int sdram_size = binfo->ram_size;
@@ -1379,10 +1380,14 @@ static void n8x0_init(MachineState *machine,
*
* The code above is for loading the `zImage' file from Nokia
* images. */
- load_image_targphys(option_rom[0].name,
+ rom_size = load_image_targphys(option_rom[0].name,
OMAP2_Q2_BASE + 0x400000,
sdram_size - 0x400000);
-
+ if (rom_size < 0) {
+ fprintf(stderr, "qemu: could not load rom file '%s'\n",
+ option_rom[0].name);
+ exit(1);
+ }
n800_setup_nolo_tags(nolo_tags);
cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x10000);
g_free(nolo_tags);
diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c
index 5cae0f1..2930f0b 100644
--- a/hw/lm32/milkymist.c
+++ b/hw/lm32/milkymist.c
@@ -86,7 +86,7 @@ milkymist_init(MachineState *machine)
const char *initrd_filename = machine->initrd_filename;
LM32CPU *cpu;
CPULM32State *env;
- int kernel_size;
+ int bios_size, kernel_size;
DriveInfo *dinfo;
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *phys_sdram = g_new(MemoryRegion, 1);
@@ -146,9 +146,14 @@ milkymist_init(MachineState *machine)
bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (bios_filename) {
- load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE);
- }
+ bios_size = load_image_targphys(bios_filename, BIOS_OFFSET,
BIOS_SIZE);
+ if (bios_size < 0) {
+ fprintf(stderr, "qemu: could not load bios '%s'\n",
+ bios_filename);
+ exit(1);
+ }
+ }
reset_info->bootstrap_pc = BIOS_OFFSET;
/* if no kernel is given no valid bios rom is a fatal error */
@@ -205,9 +210,15 @@ milkymist_init(MachineState *machine)
}
if (initrd_filename) {
- size_t initrd_size;
+ int initrd_size;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
initrd_max);
+
+ if (initrd_size < 0) {
+ fprintf(stderr, "qemu: could not load ram disk '%s'\n",
+ initrd_filename);
+ exit(1);
+ }
reset_info->initrd_base = (uint32_t)initrd_base;
reset_info->initrd_size = (uint32_t)initrd_size;
}
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index b97d966..eec7778 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -269,6 +269,11 @@ static void virtex_init(MachineState *machine)
kernel_size = load_image_targphys(kernel_filename,
boot_offset,
ram_size);
+ if (kernel_size < 0) {
+ error_report("couldn't load kernel '%s'",
+ kernel_filename);
+ exit(1);
+ }
boot_info.bootstrap_pc = boot_offset;
high = boot_info.bootstrap_pc + kernel_size + 8192;
}
--
1.9.1
next reply other threads:[~2016-10-16 0:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-16 0:48 Shreya Shrivastava [this message]
2016-10-16 16:55 ` [Qemu-devel] [PATCH 2/4] Add error checking for load_image_targphys Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a9716f112de7394c88600eb4588c15d7.webmail@localhost \
--to=pink89@sigaint.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).