Patchwork [13/13] pc_sysfw: Plug memory leak on pc_fw_add_pflash_drv() error path

login
register
mail settings
Submitter Stefan Hajnoczi
Date Dec. 7, 2012, 11:39 a.m.
Message ID <1354880352-9597-14-git-send-email-stefanha@redhat.com>
Download mbox | patch
Permalink /patch/204463/
State New
Headers show

Comments

Stefan Hajnoczi - Dec. 7, 2012, 11:39 a.m.
From: Markus Armbruster <armbru@redhat.com>

Harmless, because we the error inevitably leads to another, fatal one
in pc_system_flash_init(): PC system firmware (pflash) not available.
Fix it anyway.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/pc_sysfw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c
index 9d7c5f4..40bced2 100644
--- a/hw/pc_sysfw.c
+++ b/hw/pc_sysfw.c
@@ -98,7 +98,9 @@  static void pc_fw_add_pflash_drv(void)
       return;
     }
 
-    drive_init(opts, machine->use_scsi);
+    if (!drive_init(opts, machine->use_scsi)) {
+        qemu_opts_del(opts);
+    }
 }
 
 static void pc_system_flash_init(MemoryRegion *rom_memory,