提交 e7b7a201 编写于 作者: D Daniel P. Berrange

Fix leak of address string in qemuDomainPCIAddressGetNextSlot

qemuDomainPCIAddressGetNextSlot has a loop for finding
compatible PCI buses. In the loop body it creates a
PCI address string, but never frees this. This causes
a leak if the loop executes more than one iteration,
or if a call in the loop body fails.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 66f2db73
......@@ -2246,12 +2246,12 @@ qemuDomainPCIAddressGetNextSlot(qemuDomainPCIAddressSetPtr addrs,
/* Start the search at the last used bus and slot */
for (a.slot++; a.bus < addrs->nbuses; a.bus++) {
addrStr = NULL;
if (!(addrStr = qemuDomainPCIAddressAsString(&a)))
goto error;
if (!qemuDomainPCIAddressFlagsCompatible(&a, addrStr,
addrs->buses[a.bus].flags,
flags, false, false)) {
VIR_FREE(addrStr);
VIR_DEBUG("PCI bus %.4x:%.2x is not compatible with the device",
a.domain, a.bus);
continue;
......@@ -2264,6 +2264,7 @@ qemuDomainPCIAddressGetNextSlot(qemuDomainPCIAddressSetPtr addrs,
a.domain, a.bus, a.slot);
}
a.slot = 1;
VIR_FREE(addrStr);
}
/* There were no free slots after the last used one */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册