From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO3y5-0007he-TD for qemu-devel@nongnu.org; Tue, 26 Jan 2016 08:47:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO3y3-0003zB-Pu for qemu-devel@nongnu.org; Tue, 26 Jan 2016 08:47:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO3y3-0003z7-Kr for qemu-devel@nongnu.org; Tue, 26 Jan 2016 08:47:35 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 43D173D3F49 for ; Tue, 26 Jan 2016 13:47:35 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0QDlNqH028272 for ; Tue, 26 Jan 2016 08:47:34 -0500 From: Paolo Bonzini Date: Tue, 26 Jan 2016 14:46:38 +0100 Message-Id: <1453816041-36362-7-git-send-email-pbonzini@redhat.com> In-Reply-To: <1453816041-36362-1-git-send-email-pbonzini@redhat.com> References: <1453816041-36362-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 06/49] qemu-char: avoid leak in qemu_chr_open_pp_fd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org drv leaks if qemu_chr_alloc returns an error. Signed-off-by: Paolo Bonzini --- qemu-char.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 7ded3c2..ae813d0 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1740,18 +1740,19 @@ static CharDriverState *qemu_chr_open_pp_fd(int fd, return NULL; } - drv = g_new0(ParallelCharDriver, 1); - drv->fd = fd; - drv->mode = IEEE1284_MODE_COMPAT; - chr = qemu_chr_alloc(backend, errp); if (!chr) { return NULL; } + + drv = g_new0(ParallelCharDriver, 1); + chr->opaque = drv; chr->chr_write = null_chr_write; chr->chr_ioctl = pp_ioctl; chr->chr_close = pp_close; - chr->opaque = drv; + + drv->fd = fd; + drv->mode = IEEE1284_MODE_COMPAT; return chr; } -- 1.8.3.1