tools/libxc: Fix memory leaks in xc_domain_save()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 24 Jun 2013 15:47:05 +0000 (16:47 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 26 Jun 2013 16:22:41 +0000 (17:22 +0100)
Introduces outbuf_free() to mirror the currently existing outbuf_init().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxc/xc_domain_save.c

index ff766265df5ac6af53d71c246831e86f63363ae0..fbc15e94880dbd3ea25286b423be7142e91189b5 100644 (file)
@@ -139,6 +139,13 @@ static int outbuf_init(xc_interface *xch, struct outbuf* ob, size_t size)
     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, int io_fd, uint32_t dom, uint32_t max_iter
     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);