From: Trieu Huynh <[email protected]> Check return value of get_image_size() and return early on failure instead of continuing with invalid state. - Use ret < 0 to handle negative return value. - No functional changes.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/413 Signed-off-by: Trieu Huynh <[email protected]> --- hw/ipmi/ipmi_bmc_sim.c | 2 ++ hw/sparc/leon3.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index 012e2ee4fe..fd875491f5 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -2561,6 +2561,8 @@ static void ipmi_fru_init(IPMIFru *fru) g_free(fru->data); fru->data = NULL; } + } else { + error_report("Could not get file size '%s'", fru->filename); } out: diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index 9147d56bd4..c821dfd3bb 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -354,6 +354,11 @@ static void leon3_generic_hw_init(MachineState *machine) } else { bios_size = -1; } + if (bios_size < 0) { + error_report("could not found or failed to get file size: '%s'", + filename); + exit(1); + } if (bios_size > prom_size) { error_report("could not load prom '%s': file too big", filename); -- 2.43.0
