ch: set driver to NULL after freeing it

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>
This commit is contained in:
Daniel P. Berrangé 2021-06-04 15:59:50 +01:00
parent 85ea510624
commit b4701fe648

View 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;
}