From patchwork Sat Mar 14 11:50:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 450193 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 68E8D1400B7 for ; Sat, 14 Mar 2015 22:50:32 +1100 (AEDT) Received: from localhost ([::1]:40457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWkaM-0006yt-JV for incoming@patchwork.ozlabs.org; Sat, 14 Mar 2015 07:50:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWka6-0006iQ-3D for qemu-devel@nongnu.org; Sat, 14 Mar 2015 07:50:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWka5-00020k-5n for qemu-devel@nongnu.org; Sat, 14 Mar 2015 07:50:14 -0400 Received: from qemu.weilnetz.de ([2a03:4000:2:362::1]:50363) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWka4-00020g-VM for qemu-devel@nongnu.org; Sat, 14 Mar 2015 07:50:13 -0400 Received: by qemu.weilnetz.de (Postfix, from userid 1000) id 4472E17F713; Sat, 14 Mar 2015 12:50:10 +0100 (CET) From: Stefan Weil To: QEMU Developer Date: Sat, 14 Mar 2015 12:50:09 +0100 Message-Id: <1426333809-6112-1-git-send-email-sw@weilnetz.de> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a03:4000:2:362::1 Cc: Peter Maydell , Stefan Weil Subject: [Qemu-devel] [PATCH] hw/arm/vexpress: Fix memory leak reported by Coverity X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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/virt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 9072bc2..87b50e3 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -552,7 +552,8 @@ static void create_flash(const VirtBoardInfo *vbi) char *nodename; 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 " @@ -561,7 +562,13 @@ static void create_flash(const VirtBoardInfo *vbi) exit(1); } fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); - if (!fn || load_image_targphys(fn, flashbase, flashsize) < 0) { + if (!fn) { + error_report("Could not find ROM image '%s'", bios_name); + exit(1); + } + image_size = load_image_targphys(fn, flashbase, flashsize); + g_free(fn); + if (image_size < 0) { error_report("Could not load ROM image '%s'", bios_name); exit(1); }