From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWjnI-0003KU-TL for qemu-devel@nongnu.org; Sat, 14 Mar 2015 06:59:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWjnI-0007ix-24 for qemu-devel@nongnu.org; Sat, 14 Mar 2015 06:59:48 -0400 Received: from qemu.weilnetz.de ([2a03:4000:2:362::1]:50113) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWjnH-0007ig-RK for qemu-devel@nongnu.org; Sat, 14 Mar 2015 06:59:47 -0400 From: Stefan Weil Date: Sat, 14 Mar 2015 11:59:44 +0100 Message-Id: <1426330784-5292-1-git-send-email-sw@weilnetz.de> Subject: [Qemu-devel] [PATCH] hw/arm/vexpress: Fix memory leak reported by Coverity List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developer Cc: Peter Maydell , Stefan Weil As the conditional statement had to be splitted anyway, we can also add a better error report message. Signed-off-by: Stefan Weil --- hw/arm/vexpress.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 8496c16..54dd967 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -562,7 +562,8 @@ static void vexpress_common_init(MachineState *machine) * If a bios file was provided, attempt to map it into memory */ if (bios_name) { - const char *fn; + 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); } -- 1.7.10.4