]> git.ipfire.org Git - thirdparty/libvirt.git/commit
conf: Fix error path logic in virDomainObjListAddLocked
authorJohn Ferlan <jferlan@redhat.com>
Mon, 26 Mar 2018 22:29:30 +0000 (18:29 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 6 Apr 2018 18:14:31 +0000 (14:14 -0400)
commit2689a922aa0d637e65f0296e05454918804fd2b0
tree882156a1530b42ed35152a26d4c0fb9fe7a422d9
parent7b4964479d72366ff43aff4aa65e18f1b2619f02
conf: Fix error path logic in virDomainObjListAddLocked

If the virHashAddEntry fails, then we need to "careful" about
how we free the @vm. When virDomainObjNew 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.

Eventually these paths should goto error and error should be changed
to use EndAPI as well, but that requires more adjustments to other
paths in the code to have a locked and ref counted @vm.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/conf/virdomainobjlist.c