From patchwork Tue Sep 12 13:48:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9949263 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 585C860360 for ; Tue, 12 Sep 2017 13:50:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 493EB28FF9 for ; Tue, 12 Sep 2017 13:50:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D2E428FFF; Tue, 12 Sep 2017 13:50:53 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 D36D628FF7 for ; Tue, 12 Sep 2017 13:50:51 +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 1drlYQ-0005f6-Bm; Tue, 12 Sep 2017 13:48:42 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drlYO-0005bc-Gk for xen-devel@lists.xenproject.org; Tue, 12 Sep 2017 13:48:40 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 5C/C7-02023-7B5E7B95; Tue, 12 Sep 2017 13:48:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMIsWRWlGSWpSXmKPExsVyMfS6i+72p9s jDQ5O4LL4vmUykwOjx+EPV1gCGKNYM/OS8isSWDPezD7BWrCTr2LlkQ6mBsZl3F2MXBxCAjMY JTZ/mc4C4rAIvGSR2HvvF5gjIdDPKvHo1BoghxPISZJ4sfQ1O4SdJrH5PIjNAWSXS2zr0gcJC wnISxxsucwOMXUKk8SFrtnMIAk2AS2J+7dXsIHYIgJKEvdWTWYCsZkFUiT2rmtjBLGFBbwkmu Z8AtvFIqAq8XrjJjCbV8BRYt+nB6wQe+Ukbp7rBJvJCRRv/93FDLHYQeLKmj1sExgFFzAyrGJ UL04tKkst0rXUSyrKTM8oyU3MzNE1NDDVy00tLk5MT81JTCrWS87P3cQIDDgGINjBuLbV+RCj JAeTkiiv8v3tkUJ8SfkplRmJxRnxRaU5qcWHGDU4OAR+Pv3bwijFkpefl6okwRv2BKhOsCg1P bUiLTMHGBMwpRIcPEoivJUgad7igsTc4sx0iNQpRkuOC3cu/WHiOLDnFpDsuHn3D5MQ2Dwpcd 58kAYBkIaM0jy4cbC4vcQoKyXMywh0rBBPQWpRbmYJqvwrRnEORiVhXnuQKTyZeSVwW18BHcQ EdBDPpS0gB5UkIqSkGhhr+zf8j2PIOXPZIymD027/lrsK5bt2HA1YrN/zSXZm1VcORk+ubSu2 ZUeZlRbP2xWlUXZ7BccUR+cJAts/Z05LzDDeuzV6q8lB9wV7tPa5XQ1135V0+87p60Z2177KK p8s+ch3xvbm8855W7hOb97/o1Dx8gKm/wlbr5U4nDC4tXZJY+aLR5onlViKMxINtZiLihMBh+ brPdYCAAA= X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-9.tower-206.messagelabs.com!1505224118!111278263!1 X-Originating-IP: [209.85.215.68] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12788 invoked from network); 12 Sep 2017 13:48:39 -0000 Received: from mail-lf0-f68.google.com (HELO mail-lf0-f68.google.com) (209.85.215.68) by server-9.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 12 Sep 2017 13:48:39 -0000 Received: by mail-lf0-f68.google.com with SMTP id m199so5376184lfe.5 for ; Tue, 12 Sep 2017 06:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EMdhhfmMW0AADJAJM/+DuhrqcCg08GPL5DqWXt/DfDs=; b=qOH+dGAjYpRu5pg/tWwL4myEUXTO7CNbQO7C8Io3fu3VkH9GB3LtfoXtNHB9Hu9apl 4yqPQHYf0bClXH/O5KXfjO2uno9a9sFizGJvHLOc2Bvu9l1Ua4UMsxQbKDbp93nrB8Hl PVv1jnqmaAJCTw1b5xVIEV79vIOf9Dd3tLzpWZk7SmyvfYGNufnlSzrmaAQAhwakF4dc +Ow3/xHdfCPuInVj8AqtEnL2at8jhlSJscWjQKzqlvG8JRHFkyA7yfikMyftCyfZORyj 9sGhUGYyk59TumvTnTVqu+8wvGZAlwzuhO/v+7R491yRSG4wjTAjrA1zalOK6NLEcndH 7OVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EMdhhfmMW0AADJAJM/+DuhrqcCg08GPL5DqWXt/DfDs=; b=jScX8d+s7DNN7oeHaTnIV6hbt2190nbi7wYhfQgFi2xJSw8yY6M02Fnnm2WIaK8583 8aeQ6G9f0r86LTj6xg8X5sf+WKZ9DMUDjov44JSAlmbSwt4O0xKmm80LT8Jh4ZIaYIAB WLgSnwApwtIEU43n3axnkTKCicpKaWyGwguYuOsm8Y7mlPG6RSzKF8cr968+LdCKKjEx HR7hL2/3lpUK/s3nFAMhSSaQDZtvBshUf22CjLPv0gxPLeu/rRvd5CzgSLHQurB5XYxU 8wzM3f2YNgZyKWcK9R2+SgIssUoWZa1vNXga7Bt8bfk3Q7nJq9WooVsi1OxpiUfBCZqY Q+fQ== X-Gm-Message-State: AHPjjUippNR1YnB4Oao8CV6W86edCxD/BIBLQ2Q4r7xmiQsby/Pn0iA7 4J1AY7CqT+0ZKKQOyH8= X-Google-Smtp-Source: AOwi7QA9j5lqUPcqHMnAiBA7ekZEMBAeI9wAFgTtB+V4CQJJQPVFuavQa8UpmGabvFN5JzL6zuir5A== X-Received: by 10.25.72.16 with SMTP id v16mr3972353lfa.72.1505224118305; Tue, 12 Sep 2017 06:48:38 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-56.209.223.85.sovam.net.ua. [85.223.209.56]) by smtp.gmail.com with ESMTPSA id s5sm690074lfb.14.2017.09.12.06.48.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Sep 2017 06:48:37 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Tue, 12 Sep 2017 16:48:16 +0300 Message-Id: <1505224098-19330-12-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505224098-19330-1-git-send-email-al1img@gmail.com> References: <1505224098-19330-1-git-send-email-al1img@gmail.com> Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Oleksandr Grytsov Subject: [Xen-devel] [PATCH v6 11/13] libxl: fix memory leak in libxl__colo_save_setup 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Grytsov Getting nic list in case userspace proxy is called without freeing. The fix is to use cds->nics to keep nic list. cds->nics will be freed in devices_teardown_cb. Signed-off-by: Oleksandr Grytsov Acked-by: Wei Liu --- tools/libxl/libxl_colo_save.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl_colo_save.c b/tools/libxl/libxl_colo_save.c index bf68198..43f7dbe 100644 --- a/tools/libxl/libxl_colo_save.c +++ b/tools/libxl/libxl_colo_save.c @@ -86,7 +86,6 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) libxl__checkpoint_devices_state *const cds = &dss->cds; libxl__srm_save_autogen_callbacks *const callbacks = &dss->sws.shs.callbacks.save.a; - libxl_device_nic *nics; STATE_AO_GC(dss->ao); @@ -122,10 +121,12 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) cds->device_kind_flags = (1 << LIBXL__DEVICE_KIND_VBD); /* Use this args we can connect to qemu colo-compare */ - nics = libxl__device_list(gc, &libxl__nic_devtype, - cds->domid, "vif", &cds->num_nics); - css->cps.checkpoint_host = nics->colo_checkpoint_host; - css->cps.checkpoint_port = nics->colo_checkpoint_port; + cds->nics = libxl__device_list(gc, &libxl__nic_devtype, + cds->domid, "vif", &cds->num_nics); + if (cds->num_nics > 0) { + css->cps.checkpoint_host = cds->nics[0].colo_checkpoint_host; + css->cps.checkpoint_port = cds->nics[0].colo_checkpoint_port; + } } else { cds->device_kind_flags = (1 << LIBXL__DEVICE_KIND_VIF) | (1 << LIBXL__DEVICE_KIND_VBD);