From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Anthony Liguori <aliguori@us.ibm.com>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 10/13] qemu-char: minor mux chardev fixes
Date: Fri, 21 Jun 2013 12:38:22 +0200 [thread overview]
Message-ID: <1371811105-730-11-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1371811105-730-1-git-send-email-kraxel@redhat.com>
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>
---
qemu-char.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/qemu-char.c b/qemu-char.c
index 1c0903f..65c0c48 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3193,7 +3193,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);
@@ -3220,9 +3220,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);
@@ -3230,6 +3228,7 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
qapi_out:
qapi_free_ChardevBackend(backend);
qapi_free_ChardevReturn(ret);
+ g_free(bid);
return chr;
}
--
1.7.9.7
next prev parent reply other threads:[~2013-06-21 10:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-21 10:38 [Qemu-devel] [PATCH 00/13] A bunch of little socket + chardev fixes Gerd Hoffmann
2013-06-21 10:38 ` [Qemu-devel] [PATCH 01/13] qemu-socket: zero-initialize SocketAddress Gerd Hoffmann
2013-06-21 18:15 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2013-06-24 6:13 ` Gerd Hoffmann
2013-06-21 10:38 ` [Qemu-devel] [PATCH 02/13] qemu-socket: drop pointless allocation Gerd Hoffmann
2013-06-21 10:38 ` [Qemu-devel] [PATCH 03/13] qemu-socket: catch monitor_get_fd failures Gerd Hoffmann
2013-06-21 18:18 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2013-06-21 10:38 ` [Qemu-devel] [PATCH 04/13] qemu-char: check optional fields using has_* Gerd Hoffmann
2013-06-21 10:38 ` [Qemu-devel] [PATCH 05/13] qemu-char: use more specific error_setg_* variants Gerd Hoffmann
2013-06-21 10:38 ` [Qemu-devel] [PATCH 06/13] qemu-char: print notification to stderr Gerd Hoffmann
2013-06-21 10:38 ` [Qemu-devel] [PATCH 07/13] qemu-char: fix documentation for telnet+wait socket flags Gerd Hoffmann
2013-06-21 10:38 ` [Qemu-devel] [PATCH 08/13] qemu-char: don't leak opts on error Gerd Hoffmann
2013-06-21 10:38 ` [Qemu-devel] [PATCH 09/13] qemu-char: use ChardevBackendKind in in CharDriver Gerd Hoffmann
2013-06-21 18:36 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2013-06-21 10:38 ` Gerd Hoffmann [this message]
2013-06-21 10:38 ` [Qemu-devel] [PATCH 11/13] qemu-char: add -chardev mux support Gerd Hoffmann
2013-06-21 10:38 ` [Qemu-devel] [PATCH 12/13] qemu-char: report udb backend errors Gerd Hoffmann
2013-06-21 10:38 ` [Qemu-devel] [PATCH 13/13] qemu-socket: don't leak opts on error Gerd Hoffmann
2013-06-21 18:47 ` [Qemu-devel] [Qemu-trivial] [PATCH 00/13] A bunch of little socket + chardev fixes Michael Tokarev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371811105-730-11-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).