From patchwork Fri Jun 28 18:17:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 255497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E3EEF2C0090 for ; Sat, 29 Jun 2013 04:22:25 +1000 (EST) Received: from localhost ([::1]:36748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsdJP-0007Gw-UU for incoming@patchwork.ozlabs.org; Fri, 28 Jun 2013 14:22:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsdIl-0006gx-K3 for qemu-devel@nongnu.org; Fri, 28 Jun 2013 14:21:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UsdIi-0006on-8g for qemu-devel@nongnu.org; Fri, 28 Jun 2013 14:21:43 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:38380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsdIh-0006oR-WB; Fri, 28 Jun 2013 14:21:40 -0400 Received: from gandalf.tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id 5D3C542BCF; Fri, 28 Jun 2013 22:21:39 +0400 (MSK) Received: by gandalf.tls.msk.ru (Postfix, from userid 1000) id 6DBD1571; Fri, 28 Jun 2013 22:17:48 +0400 (MSK) From: Michael Tokarev To: Anthony Liguori Date: Fri, 28 Jun 2013 22:17:41 +0400 Message-Id: <1372443465-22384-11-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1372443465-22384-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1372443465-22384-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Michael Tokarev , Gerd Hoffmann , qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 10/14] qemu-char: minor mux chardev fixes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Gerd Hoffmann 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 Reviewed-by: Laszlo Ersek Signed-off-by: Michael Tokarev --- qemu-char.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 90754e6..392de29 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -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; }