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

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