aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorStefan Weil <sw@weilnetz.de>2015-04-01 17:57:29 +0100
committerPeter Maydell <peter.maydell@linaro.org>2015-04-01 17:57:29 +0100
commitdb25a15817f98c46c5f0eea4f414249d8fbb96b1 (patch)
treea96d097c7e35c250cc8be270ea5b42bc74e9f2b7 /hw
parent60ff4e63e2ea4738f114cbaf1f17e6e0184fc09c (diff)
hw/arm/vexpress: Fix memory leak reported by Coverity
As the conditional statement had to be split anyway, we can also add a better error report message. Signed-off-by: Stefan Weil <sw@weilnetz.de> Message-id: 1426877963-3556-1-git-send-email-sw@weilnetz.de Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/arm/vexpress.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index e9a7cede64..dd045271b8 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -563,6 +563,7 @@ static void vexpress_common_init(MachineState *machine)
*/
if (bios_name) {
char *fn;
+ int image_size;
if (drive_get(IF_PFLASH, 0, 0)) {
error_report("The contents of the first flash device may be "
@@ -571,8 +572,14 @@ static void vexpress_common_init(MachineState *machine)
exit(1);
}
fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
- if (!fn || load_image_targphys(fn, map[VE_NORFLASH0],
- VEXPRESS_FLASH_SIZE) < 0) {
+ if (!fn) {
+ error_report("Could not find ROM image '%s'", bios_name);
+ exit(1);
+ }
+ image_size = load_image_targphys(fn, map[VE_NORFLASH0],
+ VEXPRESS_FLASH_SIZE);
+ g_free(fn);
+ if (image_size < 0) {
error_report("Could not load ROM image '%s'", bios_name);
exit(1);
}