From: Peter Krempa Date: Thu, 30 Mar 2023 09:42:31 +0000 (+0200) Subject: conf: Clear pointer to freed bitmap holding hostdev's 'origstates' X-Git-Tag: v9.2.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bfd11dd852335c1274b6dc1e771bd745d1fd94d;p=thirdparty%2Flibvirt.git conf: Clear pointer to freed bitmap holding hostdev's 'origstates' 'virDomainHostdevDefClear' must clear the pointers too as it can be invoked multiple times on the same object e.g. inside qemuDomainRemoveHostDevice once via virDomainHostdevDefFree which skips freeing the object if it's used via and thus has a 'net' definition corresponding to it, and then subsequently via virDomainNetDefFree. Fix it by clearing the pointer along with freeing it. Fixes: d9e4075d4e9 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2182961 Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9f49c6e62d..08527964d1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3384,7 +3384,7 @@ void virDomainHostdevDefClear(virDomainHostdevDef *def) VIR_FREE(def->source.subsys.u.scsi_host.wwpn); break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: - virBitmapFree(def->source.subsys.u.pci.origstates); + g_clear_pointer(&def->source.subsys.u.pci.origstates, virBitmapFree); break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: