From ee6ee83de29923483b4905b35f18abf5333f6ea9 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 13 Sep 2013 12:48:47 +0200 Subject: [PATCH] chardev: handle qmp_chardev_add(KIND_MUX) failure Cc: Markus Armbruster Signed-off-by: Gerd Hoffmann --- qemu-char.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qemu-char.c b/qemu-char.c index f7f5464b67..2ca34cd710 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3271,7 +3271,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);