[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/10] hw/ppc/e500.c: Handle qemu_find_file() failure
From: |
David Gibson |
Subject: |
[PULL 01/10] hw/ppc/e500.c: Handle qemu_find_file() failure |
Date: |
Tue, 7 Apr 2020 14:35:57 +1000 |
From: Peter Maydell <address@hidden>
If qemu_find_file() doesn't find the BIOS it returns NULL; we were
passing that unchecked through to load_elf(), which assumes a non-NULL
pointer and may misbehave. In practice it fails with a weird message:
$ qemu-system-ppc -M ppce500 -display none -kernel nonesuch
Bad address
qemu-system-ppc: could not load firmware '(null)'
Handle the failure case better:
$ qemu-system-ppc -M ppce500 -display none -kernel nonesuch
qemu-system-ppc: could not find firmware/kernel file 'nonesuch'
Spotted by Coverity (CID 1238954).
Signed-off-by: Peter Maydell <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/e500.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 854cd3ac46..0d1f41197c 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -1047,6 +1047,10 @@ void ppce500_init(MachineState *machine)
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, payload_name);
+ if (!filename) {
+ error_report("could not find firmware/kernel file '%s'", payload_name);
+ exit(1);
+ }
payload_size = load_elf(filename, NULL, NULL, NULL,
&bios_entry, &loadaddr, NULL, NULL,
--
2.25.2
- [PULL 00/10] ppc-for-5.0 queue 20200407, David Gibson, 2020/04/07
- [PULL 02/10] vfio/spapr: Fix page size calculation, David Gibson, 2020/04/07
- [PULL 01/10] hw/ppc/e500.c: Handle qemu_find_file() failure,
David Gibson <=
- [PULL 03/10] ppc/spapr: KVM FWNMI should not be enabled until guest requests it, David Gibson, 2020/04/07
- [PULL 07/10] spapr: Fix failure path for attempting to hot unplug PCI bridges, David Gibson, 2020/04/07
- [PULL 04/10] ppc/spapr: Improve FWNMI machine check delivery corner case comments, David Gibson, 2020/04/07
- [PULL 08/10] hw/ppc/ppc440_uc.c: Remove incorrect iothread locking from dcr_write_pcie(), David Gibson, 2020/04/07
- [PULL 06/10] ppc/spapr: Don't kill the guest if a recovered FWNMI machine check delivery fails, David Gibson, 2020/04/07
- [PULL 05/10] ppc/spapr: Add FWNMI machine check delivery warnings, David Gibson, 2020/04/07
- [PULL 10/10] ppc/pnv: Create BMC devices only when defaults are enabled, David Gibson, 2020/04/07
- [PULL 09/10] pseries: Update SLOF firmware image, David Gibson, 2020/04/07
- Re: [PULL 00/10] ppc-for-5.0 queue 20200407, Peter Maydell, 2020/04/07