From patchwork Tue Jan 26 13:46:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 8122481 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5D913BEEE5 for ; Tue, 26 Jan 2016 13:49:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD84A20254 for ; Tue, 26 Jan 2016 13:49:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3659020253 for ; Tue, 26 Jan 2016 13:49:47 +0000 (UTC) Received: from localhost ([::1]:43929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO40A-000368-KW for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Jan 2016 08:49:46 -0500 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 To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/49] qemu-char: avoid leak in qemu_chr_open_pp_fd 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }