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

[libvirt] [PATCH] libxl: unref DomainObjPrivate on error path



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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ddd7943..f09ad61 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -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;
 }
-- 
1.8.1.4


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