Skip to contentSkip to conversation

libxl: Fix memory leak if pthread_create fails.

PATCH Jim Fehlig 1 participant 1 message Mar 26, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Jim Fehlig

author
#1 lore raw
Quoted 3 lines · Konrad Rzeszutek Wilk

If we fail to create the thread we leak the shutdown_info structure.

Nice catch, thanks! ACK and pushed.

Regards,
Jim

Quoted 27 lines
---
 src/libxl/libxl_domain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/libxl/libxl_domain.c +2 -1
index 774b070..0ac5c62 100644
@@ -482,7 +482,7 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
     libxlDriverPrivatePtr driver = data;
     virDomainObjPtr vm = NULL;
     libxl_shutdown_reason xl_reason = event->u.domain_shutdown.shutdown_reason;
-    struct libxlShutdownThreadInfo *shutdown_info;
+    struct libxlShutdownThreadInfo *shutdown_info = NULL;
     virThread thread;
     libxlDriverConfigPtr cfg;
 
@@ -535,6 +535,7 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
     virObjectUnref(cfg);
     if (vm)
         virObjectUnlock(vm);
+    VIR_FREE(shutdown_info);
 }
 
 void