diff mbox

hw/arm/vexpress: Fix memory leak reported by Coverity

Message ID 1426333809-6112-1-git-send-email-sw@weilnetz.de
State Superseded
Headers show

Commit Message

Stefan Weil March 14, 2015, 11:50 a.m. UTC
As the conditional statement had to be splitted anyway, we can also
add a better error report message.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/arm/virt.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Stefan Weil March 20, 2015, 6:57 p.m. UTC | #1
Am 14.03.2015 um 12:50 schrieb 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 <sw@weilnetz.de>
> ---
>   hw/arm/virt.c |   11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
>
>

Superseded by new patch v2.
diff mbox

Patch

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);
         }