qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 3/8] hw/arm/virt: Fix memory leak reported by Coverity
Date: Wed,  1 Apr 2015 18:08:13 +0100	[thread overview]
Message-ID: <1427908098-11358-4-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1427908098-11358-1-git-send-email-peter.maydell@linaro.org>

From: Stefan Weil <sw@weilnetz.de>

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: 1426877982-3603-1-git-send-email-sw@weilnetz.de
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/virt.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index b652b07..7d082e2 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -553,6 +553,7 @@ static void create_flash(const VirtBoardInfo *vbi)
 
     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 "
@@ -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);
         }
-- 
1.9.1

  parent reply	other threads:[~2015-04-01 17:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01 17:08 [Qemu-devel] [PULL 0/8] target-arm queue Peter Maydell
2015-04-01 17:08 ` [Qemu-devel] [PULL 1/8] hw/arm/highbank: Fix resource leak and wrong image loading Peter Maydell
2015-04-01 17:08 ` [Qemu-devel] [PULL 2/8] hw/arm/vexpress: Fix memory leak reported by Coverity Peter Maydell
2015-04-01 17:08 ` Peter Maydell [this message]
2015-04-01 17:08 ` [Qemu-devel] [PULL 4/8] target-arm: Store SPSR_EL1 state in banked_spsr[1] (SPSR_svc) Peter Maydell
2015-04-01 17:08 ` [Qemu-devel] [PULL 5/8] target-arm: kvm: save/restore mp state Peter Maydell
2015-04-01 17:08 ` [Qemu-devel] [PULL 6/8] hw/intc: arm_gic_kvm.c restore config first Peter Maydell
2015-04-01 17:08 ` [Qemu-devel] [PULL 7/8] target-arm: kvm64 sync FP register state Peter Maydell
2015-04-01 17:08 ` [Qemu-devel] [PULL 8/8] target-arm: kvm64 fix save/restore of SPSR regs Peter Maydell
2015-04-01 18:05 ` [Qemu-devel] [PULL 0/8] target-arm queue Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427908098-11358-4-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).