Skip to contentSkip to conversation

PPC: e500: Add check for NULL return value from qemu_find_file.

PATCH Applied Nia Alarie 2 participants 3 messages Mar 3, 2018 – Mar 5, 2018

lore
Share & tools
lore

Nia Alarie

author
#0 lore raw

PATCH 1/1 PPC: e500: Add check for NULL return value from qemu_find_file.

This prints a message and exits if the e500 BIOS firmware can't be found, to avoid dereferencing a null pointer.

---
 hw/ppc/e500.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/ppc/e500.c +4 -0
index a40d3ec3e3..6ce03d6ff4 100644
@@ -1005,6 +1005,10 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
         }
     }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+    if (!filename) {
+        error_report("Could not find firmware '%s'", bios_name);
+        exit(1);
+    }
 
     bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL,
                          1, PPC_ELF_MACHINE, 0, 0);
Signature · 1 line
2.16.2
Applied
#1 lore raw
Quoted 4 lines · Nia Alarie

This prints a message and exits if the e500 BIOS firmware can't be found, to avoid dereferencing a null pointer.

Applied to ppc-for-2.12, thanks.

Quoted 19 lines
---
 hw/ppc/e500.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/ppc/e500.c +4 -0
index a40d3ec3e3..6ce03d6ff4 100644
@@ -1005,6 +1005,10 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
         }
     }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+    if (!filename) {
+        error_report("Could not find firmware '%s'", bios_name);
+        exit(1);
+    }
 
     bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL,
                          1, PPC_ELF_MACHINE, 0, 0);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#2 lore raw
Quoted 7 lines · David Gibson
Quoted 4 lines · Nia Alarie

This prints a message and exits if the e500 BIOS firmware can't be found, to avoid dereferencing a null pointer.

Applied to ppc-for-2.12, thanks.

Sorry, I take that back. This has been obsoleted by other changes to the e500 image load path.

Quoted 21 lines
Quoted 20 lines
---
 hw/ppc/e500.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/ppc/e500.c +4 -0
index a40d3ec3e3..6ce03d6ff4 100644
@@ -1005,6 +1005,10 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
         }
     }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+    if (!filename) {
+        error_report("Could not find firmware '%s'", bios_name);
+        exit(1);
+    }
 
     bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL,
                          1, PPC_ELF_MACHINE, 0, 0);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson