From: "Shreya Shrivastava" <pink89@sigaint.org>
To: qemu-devel@nongnu.org
Cc: stefanha@gmail.com
Subject: [Qemu-devel] [PATCH 1/4] Add error checking for qemu_find_file.
Date: Sun, 16 Oct 2016 00:44:50 -0000 [thread overview]
Message-ID: <2e21095142cbca8b167f208551efdd5e.webmail@localhost> (raw)
This patch adds check for NULL return value to uses of qemu_find_file.
Signed-off-by: Shreya Shrivastava <pink89@sigaint.org>
---
hw/microblaze/boot.c | 5 +++++
hw/ppc/e500.c | 5 ++++-
hw/ppc/mac_newworld.c | 5 +++++
hw/ppc/mac_oldworld.c | 4 ++++
4 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c
index 9eebb1a..ba06bf5 100644
--- a/hw/microblaze/boot.c
+++ b/hw/microblaze/boot.c
@@ -127,6 +127,11 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu,
hwaddr ddr_base,
/* default to pcbios dtb as passed by machine_init */
if (!dtb_arg) {
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_filename);
+ if (!filename) {
+ error_report("qemu: could not load dtb file '%s'",
+ dtb_filename);
+ exit(EXIT_FAILURE);
+ }
}
boot_info.machine_cpu_reset = machine_cpu_reset;
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index cf8b122..3fce082 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -1014,7 +1014,10 @@ void ppce500_init(MachineState *machine,
PPCE500Params *params)
}
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
-
+ if (!filename) {
+ fprintf(stderr, "Couldn't open bios file %s\n", bios_name);
+ exit(1);
+ }
bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL,
1, PPC_ELF_MACHINE, 0, 0);
if (bios_size < 0) {
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 7d25106..9923f00 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -217,6 +217,11 @@ static void ppc_core99_init(MachineState *machine)
if (bios_name == NULL)
bios_name = PROM_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+ if (!filename) {
+ fprintf(stderr, "Couldn't open bios file %s\n",
+ bios_name);
+ exit(1);
+ }
memory_region_set_readonly(bios, true);
memory_region_add_subregion(get_system_memory(), PROM_ADDR, bios);
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 4479487..3e44c41 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -145,6 +145,10 @@ static void ppc_heathrow_init(MachineState *machine)
if (bios_name == NULL)
bios_name = PROM_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+ if (!filename) {
+ fprintf(stderr, "Couldn't open bios file %s\n", bios_name);
+ exit(1);
+ }
memory_region_set_readonly(bios, true);
memory_region_add_subregion(sysmem, PROM_ADDR, bios);
--
1.9.1
reply other threads:[~2016-10-16 0:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=2e21095142cbca8b167f208551efdd5e.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).