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

login
register
mail settings
Submitter Markus Armbruster
Date Nov. 23, 2012, 6:12 p.m.
Message ID <1353694338-13162-3-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/201388/
State New
Headers show

Comments

Markus Armbruster - Nov. 23, 2012, 6:12 p.m.
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>
---
 hw/pc_sysfw.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Stefan Hajnoczi - Dec. 3, 2012, 1:06 p.m.
On Fri, Nov 23, 2012 at 07:12:18PM +0100, Markus Armbruster wrote:
> 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>
> ---
>  hw/pc_sysfw.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan

Patch

diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c
index 066c4fe..67fe87b 100644
--- a/hw/pc_sysfw.c
+++ b/hw/pc_sysfw.c
@@ -103,7 +103,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,