cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-blockdev-fix-drive_init-opts-and-bs_opts-leaks.patch

0a122b
From 792e58622d0a5c0015673e2929c89b4bd36ef008 Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <792e58622d0a5c0015673e2929c89b4bd36ef008.1387288155.git.minovotn@redhat.com>
0a122b
In-Reply-To: <527da6c2ce2c09d0183aa8595fc95f136f61b6df.1387288155.git.minovotn@redhat.com>
0a122b
References: <527da6c2ce2c09d0183aa8595fc95f136f61b6df.1387288155.git.minovotn@redhat.com>
0a122b
From: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
Date: Thu, 12 Dec 2013 16:21:23 +0100
0a122b
Subject: [PATCH 3/8] blockdev: fix drive_init() opts and bs_opts leaks
0a122b
0a122b
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
Message-id: <1386865288-1575-4-git-send-email-stefanha@redhat.com>
0a122b
Patchwork-id: 56257
0a122b
O-Subject: [RHEL7 qemu-kvm PATCH 3/8] blockdev: fix drive_init() opts and bs_opts leaks
0a122b
Bugzilla: 1003773
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
0a122b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
0a122b
0a122b
These memory leaks also make drive_add if=none,id=drive0 without a file=
0a122b
option leak the options list.  This keeps ID "drive0" around forever.
0a122b
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
Reviewed-by: Eric Blake <eblake@redhat.com>
0a122b
(cherry picked from commit ec9c10d29c6bb5613a680af62f5825d3bb2d31d4)
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
0a122b
Conflicts:
0a122b
	blockdev.c
0a122b
0a122b
s/bdrv_delete/bdrv_unref/ upstream has resulted in a trivial conflict.
0a122b
---
0a122b
 blockdev.c | 27 +++++++++++++++------------
0a122b
 1 file changed, 15 insertions(+), 12 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 blockdev.c | 27 +++++++++++++++------------
0a122b
 1 file changed, 15 insertions(+), 12 deletions(-)
0a122b
0a122b
diff --git a/blockdev.c b/blockdev.c
0a122b
index cdd453a..f6d607c 100644
0a122b
--- a/blockdev.c
0a122b
+++ b/blockdev.c
0a122b
@@ -360,7 +360,7 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
0a122b
     qemu_opts_absorb_qdict(opts, bs_opts, &error);
0a122b
     if (error_is_set(&error)) {
0a122b
         error_propagate(errp, error);
0a122b
-        return NULL;
0a122b
+        goto early_err;
0a122b
     }
0a122b
 
0a122b
     if (id) {
0a122b
@@ -380,7 +380,7 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
0a122b
     if ((buf = qemu_opt_get(opts, "discard")) != NULL) {
0a122b
         if (bdrv_parse_discard_flags(buf, &bdrv_flags) != 0) {
0a122b
             error_setg(errp, "invalid discard option");
0a122b
-            return NULL;
0a122b
+            goto early_err;
0a122b
         }
0a122b
     }
0a122b
 
0a122b
@@ -402,7 +402,7 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
0a122b
             /* this is the default */
0a122b
         } else {
0a122b
            error_setg(errp, "invalid aio option");
0a122b
-           return NULL;
0a122b
+           goto early_err;
0a122b
         }
0a122b
     }
0a122b
 #endif
0a122b
@@ -412,13 +412,13 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
0a122b
             error_printf("Supported formats:");
0a122b
             bdrv_iterate_format(bdrv_format_print, NULL);
0a122b
             error_printf("\n");
0a122b
-            return NULL;
0a122b
+            goto early_err;
0a122b
         }
0a122b
 
0a122b
         drv = bdrv_find_whitelisted_format(buf, ro);
0a122b
         if (!drv) {
0a122b
             error_setg(errp, "'%s' invalid format", buf);
0a122b
-            return NULL;
0a122b
+            goto early_err;
0a122b
         }
0a122b
     }
0a122b
 
0a122b
@@ -438,20 +438,20 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
0a122b
 
0a122b
     if (!do_check_io_limits(&io_limits, &error)) {
0a122b
         error_propagate(errp, error);
0a122b
-        return NULL;
0a122b
+        goto early_err;
0a122b
     }
0a122b
 
0a122b
     on_write_error = BLOCKDEV_ON_ERROR_ENOSPC;
0a122b
     if ((buf = qemu_opt_get(opts, "werror")) != NULL) {
0a122b
         if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {
0a122b
             error_setg(errp, "werror is not supported by this bus type");
0a122b
-            return NULL;
0a122b
+            goto early_err;
0a122b
         }
0a122b
 
0a122b
         on_write_error = parse_block_error_action(buf, 0, &error);
0a122b
         if (error_is_set(&error)) {
0a122b
             error_propagate(errp, error);
0a122b
-            return NULL;
0a122b
+            goto early_err;
0a122b
         }
0a122b
     }
0a122b
 
0a122b
@@ -459,13 +459,13 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
0a122b
     if ((buf = qemu_opt_get(opts, "rerror")) != NULL) {
0a122b
         if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {
0a122b
             error_report("rerror is not supported by this bus type");
0a122b
-            return NULL;
0a122b
+            goto early_err;
0a122b
         }
0a122b
 
0a122b
         on_read_error = parse_block_error_action(buf, 1, &error);
0a122b
         if (error_is_set(&error)) {
0a122b
             error_propagate(errp, error);
0a122b
-            return NULL;
0a122b
+            goto early_err;
0a122b
         }
0a122b
     }
0a122b
 
0a122b
@@ -491,6 +491,8 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
0a122b
         if (has_driver_specific_opts) {
0a122b
             file = NULL;
0a122b
         } else {
0a122b
+            QDECREF(bs_opts);
0a122b
+            qemu_opts_del(opts);
0a122b
             return dinfo;
0a122b
         }
0a122b
     }
0a122b
@@ -529,12 +531,13 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
0a122b
     return dinfo;
0a122b
 
0a122b
 err:
0a122b
-    qemu_opts_del(opts);
0a122b
-    QDECREF(bs_opts);
0a122b
     bdrv_delete(dinfo->bdrv);
0a122b
     g_free(dinfo->id);
0a122b
     QTAILQ_REMOVE(&drives, dinfo, next);
0a122b
     g_free(dinfo);
0a122b
+early_err:
0a122b
+    QDECREF(bs_opts);
0a122b
+    qemu_opts_del(opts);
0a122b
     return NULL;
0a122b
 }
0a122b
 
0a122b
-- 
0a122b
1.7.11.7
0a122b