mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
qemu-char: minor mux chardev fixes
mux failure path has a memory leak. creating a mux chardev can't fail though, so just assert() that instead of fixing an error path which never ever runs anyway ... Also fix bid being leaked while being at it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
parent
99aec0123c
commit
dc2c4eca89
1 changed files with 3 additions and 4 deletions
|
@ -3186,7 +3186,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
|
|||
ChardevBackend *backend = g_new0(ChardevBackend, 1);
|
||||
ChardevReturn *ret = NULL;
|
||||
const char *id = qemu_opts_id(opts);
|
||||
const char *bid = NULL;
|
||||
char *bid = NULL;
|
||||
|
||||
if (qemu_opt_get_bool(opts, "mux", 0)) {
|
||||
bid = g_strdup_printf("%s-base", id);
|
||||
|
@ -3213,9 +3213,7 @@ 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);
|
||||
if (error_is_set(errp)) {
|
||||
goto qapi_out;
|
||||
}
|
||||
assert(!error_is_set(errp));
|
||||
}
|
||||
|
||||
chr = qemu_chr_find(id);
|
||||
|
@ -3223,6 +3221,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
|
|||
qapi_out:
|
||||
qapi_free_ChardevBackend(backend);
|
||||
qapi_free_ChardevReturn(ret);
|
||||
g_free(bid);
|
||||
return chr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue