Subject: [PATCH 16/18] chardev: handle qmp_chardev_add(KIND_MUX) failure

From: Gerd Hoffmann <[email-masked]>
Date: Mon, 14 Oct 2013 13:35:23 +0200

RH-Author: Gerd Hoffmann <[email-masked]>
Message-id: <[email-masked]>
Patchwork-id: 54860
O-Subject: [RHEL-7 qemu-kvm PATCH 15/15] chardev: handle qmp_chardev_add(KIND_MUX) failure
Bugzilla: 922010
RH-Acked-by: Hans de Goede <[email-masked]>
RH-Acked-by: Laszlo Ersek <[email-masked]>
RH-Acked-by: Paolo Bonzini <[email-masked]>

Cc: Markus Armbruster <[email-masked]>
Signed-off-by: Gerd Hoffmann <[email-masked]>
(cherry picked from commit ee6ee83de29923483b4905b35f18abf5333f6ea9)
---
 qemu-char.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Signed-off-by: Miroslav Rezanina <[email-masked]>
---
 qemu-char.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index bacc7b7..983f686 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3255,7 +3255,12 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
             backend->kind = CHARDEV_BACKEND_KIND_MUX;
             backend->mux->chardev = g_strdup(bid);
             ret = qmp_chardev_add(id, backend, errp);
-            assert(!error_is_set(errp));
+            if (error_is_set(errp)) {
+                chr = qemu_chr_find(bid);
+                qemu_chr_delete(chr);
+                chr = NULL;
+                goto qapi_out;
+            }
         }
 
         chr = qemu_chr_find(id);
-- 
1.7.1