diff mbox series

[2/2] hw/mips/boston: Fix load_elf error detection

Message ID 20211130211729.7116-3-jiaxun.yang@flygoat.com (mailing list archive)
State New, archived
Headers show
Series MIPS misc fixes | expand

Commit Message

Jiaxun Yang Nov. 30, 2021, 9:17 p.m. UTC
load_elf gives negative return in case of error, not zero.

Fixes: 10e3f30 ("hw/mips/boston: Allow loading elf kernel and dtb")
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
For 6.2.
---
 hw/mips/boston.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé Nov. 30, 2021, 9:54 p.m. UTC | #1
On 11/30/21 22:17, Jiaxun Yang wrote:
> load_elf gives negative return in case of error, not zero.
> 
> Fixes: 10e3f30 ("hw/mips/boston: Allow loading elf kernel and dtb")
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> For 6.2.
> ---
>  hw/mips/boston.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
diff mbox series

Patch

diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 0e3cca5511..296e9fa2ad 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -777,14 +777,15 @@  static void boston_mach_init(MachineState *machine)
             exit(1);
         }
     } else if (machine->kernel_filename) {
-        uint64_t kernel_entry, kernel_high, kernel_size;
+        uint64_t kernel_entry, kernel_high;
+        ssize_t kernel_size;
 
         kernel_size = load_elf(machine->kernel_filename, NULL,
                            cpu_mips_kseg0_to_phys, NULL,
                            &kernel_entry, NULL, &kernel_high,
                            NULL, 0, EM_MIPS, 1, 0);
 
-        if (kernel_size) {
+        if (kernel_size > 0) {
             int dt_size;
             g_autofree const void *dtb_file_data, *dtb_load_data;
             hwaddr dtb_paddr = QEMU_ALIGN_UP(kernel_high, 64 * KiB);