xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] libxc: fix leak of t_info in xc_tbuf_get_size()
@ 2016-02-11  8:32 Harmandeep Kaur
  2016-02-11  9:14 ` Dario Faggioli
  2016-02-11  9:52 ` Ian Campbell
  0 siblings, 2 replies; 6+ messages in thread
From: Harmandeep Kaur @ 2016-02-11  8:32 UTC (permalink / raw)
  To: xen-devel
  Cc: wei.liu2, ian.campbell, stefano.stabellini, dario.faggioli,
	ian.jackson, Harmandeep Kaur

Avoid leaking the memory mapping of the trace buffer

Coverity ID 1351228

Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
---
v2: call to unmapping function reduced to one from two
---
 tools/libxc/xc_tbuf.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c
index 695939a..d96cc67 100644
--- a/tools/libxc/xc_tbuf.c
+++ b/tools/libxc/xc_tbuf.c
@@ -70,11 +70,13 @@ int xc_tbuf_get_size(xc_interface *xch, unsigned long *size)
                     sysctl.u.tbuf_op.buffer_mfn);
 
     if ( t_info == NULL || t_info->tbuf_size == 0 )
-        return -1;
+        rc = -1;
+    else
+	*size = t_info->tbuf_size;
 
-    *size = t_info->tbuf_size;
+    xenforeignmemory_unmap(xch->fmem, t_info, *size);
 
-    return 0;
+    return rc;
 }
 
 int xc_tbuf_enable(xc_interface *xch, unsigned long pages, unsigned long *mfn,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-02-11 10:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-11  8:32 [PATCH v2] libxc: fix leak of t_info in xc_tbuf_get_size() Harmandeep Kaur
2016-02-11  9:14 ` Dario Faggioli
2016-02-11  9:52 ` Ian Campbell
2016-02-11 10:03   ` Dario Faggioli
2016-02-11 10:11     ` Ian Campbell
2016-02-11 10:23       ` Dario Faggioli

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).