xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Oleksandr Grytsov <al1img@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com,
	Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Subject: [PATCH v6 11/13] libxl: fix memory leak in libxl__colo_save_setup
Date: Tue, 12 Sep 2017 16:48:16 +0300	[thread overview]
Message-ID: <1505224098-19330-12-git-send-email-al1img@gmail.com> (raw)
In-Reply-To: <1505224098-19330-1-git-send-email-al1img@gmail.com>

From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

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 <oleksandr_grytsov@epam.com>
---
 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);
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-09-12 13:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-12 13:48 [PATCH v6 00/13] libxl: add PV display device driver interface Oleksandr Grytsov
2017-09-12 13:48 ` [PATCH v6 01/13] libxl: add generic function to add device Oleksandr Grytsov
2017-09-12 13:48 ` [PATCH v6 02/13] libxl: add generic functions to get and free device list Oleksandr Grytsov
2017-09-12 13:48 ` [PATCH v6 03/13] libxl: add vdispl device Oleksandr Grytsov
2017-09-12 13:48 ` [PATCH v6 04/13] xl: add PV display device commands Oleksandr Grytsov
2017-09-12 13:48 ` [PATCH v6 05/13] docs: add PV display driver information Oleksandr Grytsov
2017-09-12 13:48 ` [PATCH v6 06/13] libxl: change p9 to use generec add function Oleksandr Grytsov
2017-09-12 13:48 ` [PATCH v6 07/13] libxl: change vkb " Oleksandr Grytsov
2017-09-12 13:48 ` [PATCH v6 08/13] libxl: change vfb " Oleksandr Grytsov
2017-09-12 13:48 ` [PATCH v6 09/13] libxl: change disk to use generic getting list functions Oleksandr Grytsov
2017-09-12 13:48 ` [PATCH v6 10/13] libxl: change nic to use generec add function Oleksandr Grytsov
2017-09-12 16:09   ` Wei Liu
2017-09-13  8:41   ` Wei Liu
2017-09-12 13:48 ` Oleksandr Grytsov [this message]
2017-09-12 16:10   ` [PATCH v6 11/13] libxl: fix memory leak in libxl__colo_save_setup Wei Liu
2017-09-12 13:48 ` [PATCH v6 12/13] libxl: change vtpm to use generec add function Oleksandr Grytsov
2017-09-12 13:48 ` [PATCH v6 13/13] libxl: remove unneeded DEVICE_ADD macro Oleksandr Grytsov
2017-09-12 16:22 ` [PATCH v6 00/13] libxl: add PV display device driver interface Wei Liu
2017-09-13  7:59   ` Oleksandr Grytsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1505224098-19330-12-git-send-email-al1img@gmail.com \
    --to=al1img@gmail.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=oleksandr_grytsov@epam.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).