]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
ch: set driver to NULL after freeing it
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 4 Jun 2021 14:59:50 +0000 (15:59 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 9 Jun 2021 09:18:04 +0000 (10:18 +0100)
If the chStateInitialize method fails, we call chStateCleanup
which free's all global state. It fails to set the global
'ch_driver' to NULL, however, so a later attempt to open the
cloud hypervisor driver will succeed and then crash attempting
to access freed memory.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/ch/ch_driver.c

index 7baacd7400e978fc47e1ce0ad41465a8f46f67a3..ac958d73a89c1bd7eb7921910d63f142bfc703d2 100644 (file)
@@ -827,6 +827,7 @@ static int chStateCleanup(void)
     virObjectUnref(ch_driver->config);
     virMutexDestroy(&ch_driver->lock);
     g_free(ch_driver);
+    ch_driver = NULL;
 
     return 0;
 }