]> xenbits.xensource.com Git - libvirt.git/commitdiff
virstorageobj: Don't clear vols if they weren't initialized
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 14 May 2019 08:31:52 +0000 (10:31 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 14 May 2019 13:56:06 +0000 (15:56 +0200)
If virStoragePoolObjNew() fails to create new volume object list
then virObjectUnref() is called and since refcounter is 1 then
virStoragePoolObjDispose() is called which in turn calls
virStoragePoolObjClearVols() which in turn dereferences
obj->volumes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/conf/virstorageobj.c

index 1d6c9d1937002ede9044f313a8988a8ff8ec8a32..cdd9863eb80339fb15dd6a1d4701413bbaa528f6 100644 (file)
@@ -619,6 +619,9 @@ virStoragePoolSourceFindDuplicateDevices(virStoragePoolObjPtr obj,
 void
 virStoragePoolObjClearVols(virStoragePoolObjPtr obj)
 {
+    if (!obj->volumes)
+        return;
+
     virHashRemoveAll(obj->volumes->objsKey);
     virHashRemoveAll(obj->volumes->objsName);
     virHashRemoveAll(obj->volumes->objsPath);