[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/4] Add error checking for qemu_find_file.
From: |
Shreya Shrivastava |
Subject: |
[Qemu-devel] [PATCH 1/4] Add error checking for qemu_find_file. |
Date: |
Sun, 16 Oct 2016 00:44:50 -0000 |
This patch adds check for NULL return value to uses of qemu_find_file.
Signed-off-by: Shreya Shrivastava <address@hidden>
---
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH 1/4] Add error checking for qemu_find_file.,
Shreya Shrivastava <=