qemuDomainDiskPrivateDispose: Prevent dangling 'disk' pointer in blockjob data

Clear the 'disk' member of 'blockjob' as we're freeing the disk object
at this point. While this should not normally happen it was observed
when other bug allowed the VM to be cleared while other threads didn't
yet finish.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2024-06-11 15:50:52 +02:00
parent 737f897c29
commit b4423a753b

View File

@ -798,7 +798,13 @@ qemuDomainDiskPrivateDispose(void *obj)
virObjectUnref(priv->migrSource);
g_free(priv->qomName);
g_free(priv->nodeCopyOnRead);
virObjectUnref(priv->blockjob);
if (priv->blockjob) {
/* Prevent dangling 'disk' pointer, as the disk object will be freed
* right after this function returns if any of the blockjob instance
* outlives this for any reason. */
priv->blockjob->disk = NULL;
virObjectUnref(priv->blockjob);
}
}
static virClass *qemuDomainStorageSourcePrivateClass;