[PATCH 2/4] conf: Fix error path logic in virDomainObjListLoadStatus

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

 



If the virHashAddEntry fails, then we need to "careful" about
how we free the @obj. When virDomainObjParseFile returns there
is one reference and the object is locked, so use virDomainObjEndAPI
when done.

Add a virObjectRef in the error path for the second virHashAddEntry
call since it doesn't call virObjectRef, but virHashRemoveEntry
will call virObjectUnref because virObjectFreeHashData is called
when the element is removed from the hash table as set up in
virDomainObjListNew.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/virdomainobjlist.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 2ae8a41a1..765f46d5a 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -536,6 +536,7 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms,
         goto error;
 
     if (virHashAddEntry(doms->objsName, obj->def->name, obj) < 0) {
+        virObjectRef(obj);
         virHashRemoveEntry(doms->objs, uuidstr);
         goto error;
     }
@@ -551,7 +552,7 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms,
     return obj;
 
  error:
-    virObjectUnref(obj);
+    virDomainObjEndAPI(&obj);
     VIR_FREE(statusFile);
     return NULL;
 }
-- 
2.13.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux