From patchwork Thu Jun 8 13:15:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Owen Smith X-Patchwork-Id: 9774685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ED91E603B4 for ; Thu, 8 Jun 2017 13:19:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFA5E208C2 for ; Thu, 8 Jun 2017 13:19:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4672283BA; Thu, 8 Jun 2017 13:19:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6E52C212BE for ; Thu, 8 Jun 2017 13:19:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIxJG-0001WD-JL; Thu, 08 Jun 2017 13:17:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIxJF-0001VC-KL for xen-devel@lists.xenproject.org; Thu, 08 Jun 2017 13:17:09 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id 17/B4-01734-45E49395; Thu, 08 Jun 2017 13:17:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjkeJIrShJLcpLzFFi42JxWrrBXjfAzzL S4OYhBYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP/qjtsBVv4Ku6db2VvYNzC3cXIySEh4C+x f85xRhCbTUBDYkbnYhYQW0RAWqJ/Tjt7FyMXB7PANEaJ7xfWgxUJC3hIrFs+iRnEZhFQkWhZ8 gasgVfAVeLmpy3MEEPlJM4f/wlmcwq4SWzZ0QFmCwHVNP/4zQphK0l8W/yCGaJXUOLkzCdgc5 gFJCQOvnjBPIGRdxaS1CwkqQWMTKsYNYpTi8pSi3QNDfWSijLTM0pyEzNzdA0NTPVyU4uLE9N TcxKTivWS83M3MQLDhwEIdjCubHc+xCjJwaQkyqsoYBkpxJeUn1KZkVicEV9UmpNafIhRhoND SYL3vw9QTrAoNT21Ii0zBxjIMGkJDh4lEYg0b3FBYm5xZjpE6hSjopQ4L7svUEIAJJFRmgfXB oueS4yyUsK8jECHCPEUpBblZpagyr9iFOdgVBLmdQOZwpOZVwI3/RXQYiagxUveWYAsLklESE k1MNp8T8yeMvuaRwxnYsl9I4m9E9o3LJKtVHiv/0Hy9gZ23glKDKHbCyb0rfu3UsfodKldefK 04/V/ludWmml1NcxkneX64cK2A0dmJejILtkxx4W1Z17SnM9rJNdwpJ2ce6m62G9ZdVXulYcu wi032T5Ne39h0ZafVneZHHh+qcstb63Q6M2J1VBiKc5INNRiLipOBADoLwNomQIAAA== X-Env-Sender: prvs=325bb5210=owen.smith@citrix.com X-Msg-Ref: server-14.tower-206.messagelabs.com!1496927821!63649649!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34257 invoked from network); 8 Jun 2017 13:17:04 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-14.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 8 Jun 2017 13:17:04 -0000 X-IronPort-AV: E=Sophos;i="5.39,315,1493683200"; d="scan'208";a="435636365" From: Owen Smith To: Date: Thu, 8 Jun 2017 13:15:34 +0000 Message-ID: <1496927734-29174-5-git-send-email-owen.smith@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1496927734-29174-1-git-send-email-owen.smith@citrix.com> References: <1496927734-29174-1-git-send-email-owen.smith@citrix.com> MIME-Version: 1.0 Cc: anthony.perard@citrix.com, xen-devel@lists.xenproject.org, sstabellini@kernel.org, kraxel@redhat.com, Owen Smith Subject: [Xen-devel] [PATCH 4/4] xenfb: Fix leak by adding/removing keyboard handler X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Calls qemu_remove_kbd_event_handler that frees its memory, instead of adding (and allocating some memory) a new NULL handler. Signed-off-by: Owen Smith --- hw/display/xenfb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index b0a5726..570ecdb 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -55,6 +55,7 @@ struct XenInput { int vkbd_standalone; /* Guest supports vkbd without vfb device */ int button_state; /* Last seen pointer button state */ int extended; + QEMUPutKbdEntry *qkbd; QEMUPutMouseEntry *qmouse; }; @@ -365,7 +366,6 @@ static int input_initialise(struct XenDevice *xendev) if (rc != 0) return rc; - qemu_add_kbd_event_handler(xenfb_key_event, in); return 0; } @@ -378,10 +378,14 @@ static void input_connected(struct XenDevice *xendev) in->abs_pointer_wanted = 0; } + if (in->qkbd) { + qemu_remove_kbd_event_handler(in->qkbd); + } if (in->qmouse) { qemu_remove_mouse_event_handler(in->qmouse); } trace_xenfb_input_connected(xendev, in->abs_pointer_wanted); + in->qkbd = qemu_add_kbd_event_handler(xenfb_key_event, in); in->qmouse = qemu_add_mouse_event_handler(xenfb_mouse_event, in, in->abs_pointer_wanted, "Xen PVFB Mouse"); @@ -392,11 +396,14 @@ static void input_disconnect(struct XenDevice *xendev) { struct XenInput *in = container_of(xendev, struct XenInput, c.xendev); + if (in->qkbd) { + qemu_remove_kbd_event_handler(in->qkbd); + in->qkbd = NULL; + } if (in->qmouse) { qemu_remove_mouse_event_handler(in->qmouse); in->qmouse = NULL; } - qemu_add_kbd_event_handler(NULL, NULL); common_unbind(&in->c); }