Skip to contentSkip to conversation

milkymist: Check for failure trying to load BIOS image

PATCH In review Peter Maydell 3 participants 4 messages Oct 30, 2018 – Nov 5, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 milkymist: Check for failure trying to load BIOS image

Check the return value from load_image_targphys(), which tells us whether our attempt to load the BIOS image into RAM failed. (Spotted by Coverity, CID 1190305.)

---
 hw/lm32/milkymist.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/lm32/milkymist.c +4 -1
index 321f184595e..63c6894c955 100644
@@ -138,7 +138,10 @@ milkymist_init(MachineState *machine)
     bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
 
     if (bios_filename) {
-        load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE);
+        if (load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE) < 0) {
+            error_report("could not load bios '%s'", bios_filename);
+            exit(1);
+        }
     }
 
     reset_info->bootstrap_pc = BIOS_OFFSET;
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Peter Maydell

Check the return value from load_image_targphys(), which tells us whether our attempt to load the BIOS image into RAM failed. (Spotted by Coverity, CID 1190305.)

Quoted 21 lines
---
  hw/lm32/milkymist.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
hw/lm32/milkymist.c +4 -1
index 321f184595e..63c6894c955 100644
@@ -138,7 +138,10 @@ milkymist_init(MachineState *machine)
      bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
 
      if (bios_filename) {
-        load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE);
+        if (load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE) < 0) {
+            error_report("could not load bios '%s'", bios_filename);
+            exit(1);
+        }
      }
 
      reset_info->bootstrap_pc = BIOS_OFFSET;
Acked-by on v1 1/1
#2 lore raw
In reply to Peter Maydell

Am 2018-10-30 18:00, schrieb Peter Maydell:

Quoted 5 lines

Check the return value from load_image_targphys(), which tells us whether our attempt to load the BIOS image into RAM failed. (Spotted by Coverity, CID 1190305.)

Will you put it in your queue, Peter?

-michael

Quoted 21 lines
---
 hw/lm32/milkymist.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/lm32/milkymist.c +4 -1
index 321f184595e..63c6894c955 100644
@@ -138,7 +138,10 @@ milkymist_init(MachineState *machine)
     bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
 
     if (bios_filename) {
-        load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE);
+        if (load_image_targphys(bios_filename, BIOS_OFFSET, BIOS_SIZE) 
 < 0) {
+            error_report("could not load bios '%s'", bios_filename);
+            exit(1);
+        }
     }
 
     reset_info->bootstrap_pc = BIOS_OFFSET;
#3 lore raw
Quoted 6 lines · Michael Walle

Am 2018-10-30 18:00, schrieb Peter Maydell:

Quoted 5 lines

Check the return value from load_image_targphys(), which tells us whether our attempt to load the BIOS image into RAM failed. (Spotted by Coverity, CID 1190305.)

Quoted 6 lines
Quoted 1 line

Will you put it in your queue, Peter?

Sure, I have an arm pullreq I'm putting together anyway.

thanks
-- PMM