This function is supposed to clean up virQEMUDriver structure and free individual members. However, it's doing that in random order which makes it hard to track which members are being freed and which are not. Do the free in reverse order than the structure definition - assuming that the most important members (like mutex) are declared first and freed last.
Signed-off-by: Michal Privoznik <mpriv...@redhat.com> --- src/qemu/qemu_driver.c | 43 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 65c3be58d3..0b9e31b344 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1122,38 +1122,29 @@ qemuStateCleanup(void) if (!qemu_driver) return -1; - if (qemu_driver->lockFD != -1) - virPidFileRelease(qemu_driver->config->stateDir, "driver", qemu_driver->lockFD); - virThreadPoolFree(qemu_driver->workerPool); - virObjectUnref(qemu_driver->config); - virObjectUnref(qemu_driver->hostdevMgr); - virHashFree(qemu_driver->sharedDevices); - virObjectUnref(qemu_driver->caps); - virObjectUnref(qemu_driver->qemuCapsCache); - - virObjectUnref(qemu_driver->domains); - virPortAllocatorRangeFree(qemu_driver->remotePorts); - virPortAllocatorRangeFree(qemu_driver->webSocketPorts); - virPortAllocatorRangeFree(qemu_driver->migrationPorts); virObjectUnref(qemu_driver->migrationErrors); - - virObjectUnref(qemu_driver->xmlopt); - - virSysinfoDefFree(qemu_driver->hostsysinfo); - virObjectUnref(qemu_driver->closeCallbacks); - - VIR_FREE(qemu_driver->qemuImgBinary); - + virLockManagerPluginUnref(qemu_driver->lockManager); + virSysinfoDefFree(qemu_driver->hostsysinfo); + virPortAllocatorRangeFree(qemu_driver->migrationPorts); + virPortAllocatorRangeFree(qemu_driver->webSocketPorts); + virPortAllocatorRangeFree(qemu_driver->remotePorts); + virHashFree(qemu_driver->sharedDevices); + virObjectUnref(qemu_driver->hostdevMgr); virObjectUnref(qemu_driver->securityManager); - - ebtablesContextFree(qemu_driver->ebtables); - - /* Free domain callback list */ virObjectUnref(qemu_driver->domainEventState); + virObjectUnref(qemu_driver->qemuCapsCache); + virObjectUnref(qemu_driver->xmlopt); + virObjectUnref(qemu_driver->caps); + ebtablesContextFree(qemu_driver->ebtables); + VIR_FREE(qemu_driver->qemuImgBinary); + virObjectUnref(qemu_driver->domains); + virThreadPoolFree(qemu_driver->workerPool); - virLockManagerPluginUnref(qemu_driver->lockManager); + if (qemu_driver->lockFD != -1) + virPidFileRelease(qemu_driver->config->stateDir, "driver", qemu_driver->lockFD); + virObjectUnref(qemu_driver->config); virMutexDestroy(&qemu_driver->lock); VIR_FREE(qemu_driver); -- 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list