From patchwork Tue Jan 17 20:49:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 9521913 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 0332460244 for ; Tue, 17 Jan 2017 20:51:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F06EF26E64 for ; Tue, 17 Jan 2017 20:51:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3DF3285B8; Tue, 17 Jan 2017 20:51:36 +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 80BBF26E64 for ; Tue, 17 Jan 2017 20:51:36 +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 1cTahR-0007n3-0i; Tue, 17 Jan 2017 20:49:49 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTahP-0007mG-Rc for xen-devel@lists.xenproject.org; Tue, 17 Jan 2017 20:49:47 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id CE/13-25337-B638E785; Tue, 17 Jan 2017 20:49:47 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42JxWrohUjeruS7 C4NYhbYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePukc0sBb+4K9ZdXs/YwLiJq4uRg0NCwF9i XUNeFyMnB5uAgcSpTYtYQGwRAUmJqxuesHcxcnEwCyxnlNix/ihYQljAS+Jay14mkF4WAVWJD ZMyQcK8Ap4SZx6+ZgSxJQQUJKY8fM8MYnMClX+du4MNxBYCqpm1rZkVwlaTONq1iwWiV1Di5M wnYDazgITEwRcvmCcw8s5CkpqFJLWAkWkVo3pxalFZapGuhV5SUWZ6RkluYmaOrqGBmV5uanF xYnpqTmJSsV5yfu4mRmDgMADBDsbZl/0PMUpyMCmJ8nY8ro0Q4kvKT6nMSCzOiC8qzUktPsQo w8GhJMHL11QXISRYlJqeWpGWmQMMYZi0BAePkgjv0UagNG9xQWJucWY6ROoUoy7HqRunXzIJs eTl56VKifNagcwQACnKKM2DGwGLp0uMslLCvIxARwnxFKQW5WaWoMq/YhTnYFQS5rUHmcKTmV cCt+kV0BFMQEdc16kGOaIkESEl1cBY3T9r5/Wlgj/Uz/FYla638axsWdy+J7xMt4wvbr/e3wi VbcWq3Mx//zqsTyhj/nth6sfFB1Zmqr+VfVJmlJh29YRNv/S1zYclGO8f6ori5zvryBpf+OzW xQ+nPPaEZf/f6yDGfXbTfc8XN5rTX/r9uPOD1Vlk8jNDMbG0Te/LbsQ8KzZM/1mrxFKckWiox VxUnAgAU1utjqICAAA= X-Env-Sender: prvs=183722f83=igor.druzhinin@citrix.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1484686185!72906069!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2769 invoked from network); 17 Jan 2017 20:49:46 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-13.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 Jan 2017 20:49:46 -0000 X-IronPort-AV: E=Sophos;i="5.33,246,1477958400"; d="scan'208";a="400304876" From: Igor Druzhinin To: Date: Tue, 17 Jan 2017 20:49:37 +0000 Message-ID: <1484686178-76959-2-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1484686178-76959-1-git-send-email-igor.druzhinin@citrix.com> References: <1484686178-76959-1-git-send-email-igor.druzhinin@citrix.com> MIME-Version: 1.0 Cc: xen-devel@lists.xenproject.org, Igor Druzhinin , Paul.Durrant@citrix.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [Xen-devel] [PATCH v2 1/2] xen-netback: fix memory leaks on XenBus disconnect 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 Eliminate memory leaks introduced several years ago by cleaning the queue resources which are allocated on XenBus connection event. Namely, queue structure array and pages used for IO rings. Signed-off-by: Igor Druzhinin Reviewed-by: Paul Durrant Acked-by: Wei Liu --- drivers/net/xen-netback/xenbus.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c index 6c57b02..3e99071 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c @@ -493,11 +493,20 @@ static int backend_create_xenvif(struct backend_info *be) static void backend_disconnect(struct backend_info *be) { if (be->vif) { + unsigned int queue_index; + xen_unregister_watchers(be->vif); #ifdef CONFIG_DEBUG_FS xenvif_debugfs_delif(be->vif); #endif /* CONFIG_DEBUG_FS */ xenvif_disconnect_data(be->vif); + for (queue_index = 0; queue_index < be->vif->num_queues; ++queue_index) + xenvif_deinit_queue(&be->vif->queues[queue_index]); + + vfree(be->vif->queues); + be->vif->num_queues = 0; + be->vif->queues = NULL; + xenvif_disconnect_ctrl(be->vif); } } @@ -1026,6 +1035,8 @@ static void connect(struct backend_info *be) err: if (be->vif->num_queues > 0) xenvif_disconnect_data(be->vif); /* Clean up existing queues */ + for (queue_index = 0; queue_index < be->vif->num_queues; ++queue_index) + xenvif_deinit_queue(&be->vif->queues[queue_index]); vfree(be->vif->queues); be->vif->queues = NULL; be->vif->num_queues = 0;