]> xenbits.xensource.com Git - libvirt.git/commitdiff
libxl: unref DomainObjPrivate on error path
authorJim Fehlig <jfehlig@suse.com>
Thu, 15 Aug 2013 16:03:17 +0000 (10:03 -0600)
committerJim Fehlig <jfehlig@suse.com>
Thu, 15 Aug 2013 16:49:14 +0000 (10:49 -0600)
There is a potential leak of a newly created libxlDomainObjPrivate
when subsequent allocation of the object's chrdev field fails.
Unref the object on such an error so that it is properly disposed.

src/libxl/libxl_driver.c

index ddd794304f16c51164eab1183ec21e42a417b26d..f09ad6142cf0feb5f77cb642a53cdf36738d7148 100644 (file)
@@ -454,8 +454,10 @@ libxlDomainObjPrivateAlloc(void)
     if (!(priv = virObjectLockableNew(libxlDomainObjPrivateClass)))
         return NULL;
 
-    if (!(priv->devs = virChrdevAlloc()))
+    if (!(priv->devs = virChrdevAlloc())) {
+        virObjectUnref(priv);
         return NULL;
+    }
 
     return priv;
 }