Inside of bhyveDomainAssignPCIAddresses() the @addr variable is
allocated and in a few cases stolen into domain private data. But
in all other cases the associated memory is never freed.
12,800 (3,200 direct, 9,600 indirect) bytes in 100 blocks are definitely lost in loss record 533 of 538
at 0x4888098: calloc (vg_replace_malloc.c:1682)
by 0x4EE67D9: g_malloc0_n (in /usr/local/lib/libglib-2.0.so.0.8400.4)
by 0x4AFD4AC: virDomainPCIAddressSetAlloc (domain_addr.c:1011)
by 0x4020F68: bhyveDomainPCIAddressSetCreate (bhyve_device.c:65)
by 0x40210BD: bhyveDomainAssignPCIAddresses (bhyve_device.c:219)
by 0x402180C: bhyveDomainAssignAddresses (bhyve_device.c:241)
by 0x4020083: bhyveDomainDefAssignAddresses (bhyve_domain.c:230)
by 0x4B71820: virDomainDefPostParse (domain_postparse.c:1503)
by 0x4B28282: virDomainDefParseNode (domain_conf.c:20565)
by 0x4B2810B: virDomainDefParse (domain_conf.c:20502)
by 0x4B281DF: virDomainDefParseFile (domain_conf.c:20549)
by 0x4015D6B: testCompareXMLToArgvFiles (bhyvexml2argvtest.c:47)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
{
virDomainPCIAddressSet *addrs = NULL;
bhyveDomainObjPrivate *priv = NULL;
+ int ret = -1;
if (!(addrs = bhyveDomainPCIAddressSetCreate(def, 1)))
return -1;
if (bhyveAssignDevicePCISlots(def, addrs) < 0)
- return -1;
+ goto cleanup;
if (obj && obj->privateData) {
priv = obj->privateData;
if (addrs) {
virDomainPCIAddressSetFree(priv->pciaddrs);
priv->persistentAddrs = 1;
- priv->pciaddrs = addrs;
+ priv->pciaddrs = g_steal_pointer(&addrs);
} else {
priv->persistentAddrs = 0;
}
}
- return 0;
+ ret = 0;
+ cleanup:
+ virDomainPCIAddressSetFree(addrs);
+ return ret;
}
int bhyveDomainAssignAddresses(virDomainDef *def, virDomainObj *obj)