From 0cf3bb805c6f5fd42e705567b74df1423b0aaed3 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 14 May 2019 10:31:52 +0200 Subject: [PATCH] virstorageobj: Don't clear vols if they weren't initialized 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 Reviewed-by: Erik Skultety --- src/conf/virstorageobj.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 1d6c9d1937..cdd9863eb8 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -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);