cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
218e99
From c4a5b67ffac094aa1653de8e9369585b0bc4ee46 Mon Sep 17 00:00:00 2001
218e99
From: Gerd Hoffmann <kraxel@redhat.com>
218e99
Date: Mon, 14 Oct 2013 13:35:19 +0200
218e99
Subject: [PATCH 12/18] qemu-char: minor mux chardev fixes
218e99
218e99
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
218e99
Message-id: <1381757723-23134-12-git-send-email-kraxel@redhat.com>
218e99
Patchwork-id: 54861
218e99
O-Subject: [RHEL-7 qemu-kvm PATCH 11/15] qemu-char: minor mux chardev fixes
218e99
Bugzilla: 922010
218e99
RH-Acked-by: Hans de Goede <hdegoede@redhat.com>
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
218e99
mux failure path has a memory leak.  creating a mux chardev can't
218e99
fail though, so just assert() that instead of fixing an error path
218e99
which never ever runs anyway ...
218e99
218e99
Also fix bid being leaked while being at it.
218e99
218e99
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
218e99
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
218e99
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
218e99
(cherry picked from commit dc2c4eca89ec5ee7b7a4c2563c991a14a7c5ee84)
218e99
---
218e99
 qemu-char.c | 7 +++----
218e99
 1 file changed, 3 insertions(+), 4 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 qemu-char.c |    7 +++----
218e99
 1 files changed, 3 insertions(+), 4 deletions(-)
218e99
218e99
diff --git a/qemu-char.c b/qemu-char.c
218e99
index b41bda4..145fd30 100644
218e99
--- a/qemu-char.c
218e99
+++ b/qemu-char.c
218e99
@@ -3213,7 +3213,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
218e99
         ChardevBackend *backend = g_new0(ChardevBackend, 1);
218e99
         ChardevReturn *ret = NULL;
218e99
         const char *id = qemu_opts_id(opts);
218e99
-        const char *bid = NULL;
218e99
+        char *bid = NULL;
218e99
 
218e99
         if (qemu_opt_get_bool(opts, "mux", 0)) {
218e99
             bid = g_strdup_printf("%s-base", id);
218e99
@@ -3240,9 +3240,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
218e99
             backend->kind = CHARDEV_BACKEND_KIND_MUX;
218e99
             backend->mux->chardev = g_strdup(bid);
218e99
             ret = qmp_chardev_add(id, backend, errp);
218e99
-            if (error_is_set(errp)) {
218e99
-                goto qapi_out;
218e99
-            }
218e99
+            assert(!error_is_set(errp));
218e99
         }
218e99
 
218e99
         chr = qemu_chr_find(id);
218e99
@@ -3251,6 +3249,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
218e99
     qapi_out:
218e99
         qapi_free_ChardevBackend(backend);
218e99
         qapi_free_ChardevReturn(ret);
218e99
+        g_free(bid);
218e99
         return chr;
218e99
     }
218e99
 
218e99
-- 
218e99
1.7.1
218e99