[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] xenbus: fix memory leak in failure path by freeing context



In certain error paths, the context memory was not being released,
causing a potential memory leak. Ensure that __CacheFree() and
__GnttabFree() are called on failure to properly release resources
and reset the context.

Signed-off-by: david ambu <david.preetham@xxxxxxxxx>
---
 src/xenbus/cache.c  | 2 ++
 src/xenbus/gnttab.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/xenbus/cache.c b/src/xenbus/cache.c
index d60ae29..e34504b 100644
--- a/src/xenbus/cache.c
+++ b/src/xenbus/cache.c
@@ -1274,6 +1274,8 @@ fail2:
 
     RtlZeroMemory(&(*Context)->DebugInterface,
                   sizeof (XENBUS_DEBUG_INTERFACE));
+    __CacheFree(*Context);
+    *Context = NULL;
 
 fail1:
     Error("fail1 (%08x)\n", status);
diff --git a/src/xenbus/gnttab.c b/src/xenbus/gnttab.c
index 693e9b3..d3bd0ae 100644
--- a/src/xenbus/gnttab.c
+++ b/src/xenbus/gnttab.c
@@ -1138,6 +1138,8 @@ GnttabInitialize(
 
 fail2:
     Error("fail2\n");
+    __GnttabFree(*Context);
+    *Context = NULL;
 
 fail1:
     Error("fail1 (%08x)\n", status);
-- 
2.46.1.windows.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.