Skip to contentSkip to conversation

ppc/pnv: check for OPAL firmware file presence

PATCH Applied Cédric Le Goater 3 participants 3 messages Sep 25, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ppc/pnv: check for OPAL firmware file presence

and exit before uselessly trying to load it if the file does not exists.

Issue discovered by Coverity Scan.

---

Changes since v1:

- fixed spelling
- improved OPAL naming by adding firmware

 hw/ppc/pnv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/ppc/pnv.c +5 -1
index 47221158d415..d46d91c76f5c 100644
@@ -570,10 +570,14 @@ static void ppc_powernv_init(MachineState *machine)
     }
 
     fw_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+    if (!fw_filename) {
+        error_report("Could not find OPAL firmware '%s'", bios_name);
+        exit(1);
+    }
 
     fw_size = load_image_targphys(fw_filename, FW_LOAD_ADDR, FW_MAX_SIZE);
     if (fw_size < 0) {
-        error_report("Could not load OPAL '%s'", fw_filename);
+        error_report("Could not load OPAL firmware '%s'", fw_filename);
         exit(1);
     }
     g_free(fw_filename);
Signature · 1 line
2.13.5
Reviewed-by on v2 1/1
#1 lore raw
Quoted 27 lines · Cédric Le Goater

and exit before uselessly trying to load it if the file does not exists.

Issue discovered by Coverity Scan.

---

Changes since v1:

- fixed spelling
- improved OPAL naming by adding firmware

 hw/ppc/pnv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/ppc/pnv.c +2 -0
index 47221158d415..d46d91c76f5c 100644
@@ -570,10 +570,14 @@ static void ppc_powernv_init(MachineState *machine)
     }
 
     fw_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+    if (!fw_filename) {
+        error_report("Could not find OPAL firmware '%s'", bios_name);

hw/ppc/pnv.c static void ppc_powernv_init(MachineState *machine) · line 583

Quoted 10 lines
hw/ppc/pnv.c +3 -1
+        exit(1);
+    }
 
     fw_size = load_image_targphys(fw_filename, FW_LOAD_ADDR, FW_MAX_SIZE);
     if (fw_size < 0) {
-        error_report("Could not load OPAL '%s'", fw_filename);
+        error_report("Could not load OPAL firmware '%s'", fw_filename);
         exit(1);
     }
     g_free(fw_filename);
Applied
#2 lore raw
In reply to Cédric Le Goater
Quoted 6 lines · Cédric Le Goater

and exit before uselessly trying to load it if the file does not exists.

Issue discovered by Coverity Scan.

Applied to ppc-for-2.11, thanks.

Quoted 30 lines

---

Changes since v1:

- fixed spelling
- improved OPAL naming by adding firmware

 hw/ppc/pnv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/ppc/pnv.c +5 -1
index 47221158d415..d46d91c76f5c 100644
@@ -570,10 +570,14 @@ static void ppc_powernv_init(MachineState *machine)
     }
 
     fw_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+    if (!fw_filename) {
+        error_report("Could not find OPAL firmware '%s'", bios_name);
+        exit(1);
+    }
 
     fw_size = load_image_targphys(fw_filename, FW_LOAD_ADDR, FW_MAX_SIZE);
     if (fw_size < 0) {
-        error_report("Could not load OPAL '%s'", fw_filename);
+        error_report("Could not load OPAL firmware '%s'", fw_filename);
         exit(1);
     }
     g_free(fw_filename);
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