From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH] tools/libxc: Fix memory leaks in xc_domain_save() Date: Mon, 24 Jun 2013 16:47:05 +0100 Message-ID: <6f255399bd674951a104.1372088825@andrewcoop.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: George Dunlap , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org Introduces outbuf_free() to mirror the currently existing outbuf_init(). Signed-off-by: Andrew Cooper -- George: Same comment regarding consideration for 4.3 Ian: This should be considered for backporting to 4.2 and 4.1 as well diff -r 803ad8977a81 -r 6f255399bd67 tools/libxc/xc_domain_save.c --- a/tools/libxc/xc_domain_save.c +++ b/tools/libxc/xc_domain_save.c @@ -139,6 +139,13 @@ static int outbuf_init(xc_interface *xch return 0; } +static int outbuf_free(struct outbuf *ob) +{ + free(ob->buf); + ob->buf = NULL; + return 0; +} + static inline int outbuf_write(xc_interface *xch, struct outbuf* ob, void* buf, size_t len) { @@ -2122,6 +2129,8 @@ int xc_domain_save(xc_interface *xch, in free(pfn_batch); free(pfn_err); free(to_fix); + free(hvm_buf); + outbuf_free(&ob_pagebuf); DPRINTF("Save exit of domid %u with rc=%d\n", dom, rc);