]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
blockdev: Plug memory leak in blockdev_init()
authorMarkus Armbruster <armbru@redhat.com>
Wed, 28 May 2014 09:17:01 +0000 (11:17 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 5 Aug 2014 16:41:40 +0000 (11:41 -0500)
blockdev_init() leaks bs_opts when qemu_opts_create() fails, i.e. when
the ID is bad.  Missed in commit ec9c10d.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 6376f9522372d589f3efe60001dc0486237dd375)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
blockdev.c

index fbfdc27987a35a00679f19239b7bd478ee392fc3..b0ce4f0bf9be1b1a2d48c29d4f6266d50c322954 100644 (file)
@@ -332,7 +332,7 @@ static DriveInfo *blockdev_init(const char *file, QDict *bs_opts,
     opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error);
     if (error) {
         error_propagate(errp, error);
-        return NULL;
+        goto err_no_opts;
     }
 
     qemu_opts_absorb_qdict(opts, bs_opts, &error);
@@ -527,8 +527,9 @@ err:
     QTAILQ_REMOVE(&drives, dinfo, next);
     g_free(dinfo);
 early_err:
-    QDECREF(bs_opts);
     qemu_opts_del(opts);
+err_no_opts:
+    QDECREF(bs_opts);
     return NULL;
 }