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

Fix use of uninitialized memory when releasing PCI slots

The 'function' field in the PCI address was not correctly
initialized, so it was building the wrong address address
string and so not removing all functions from the in use
list.

* src/qemu/qemu_command.c: Fix initialization of PCI function
上级 9f40b80b
...@@ -931,14 +931,14 @@ int qemuDomainPCIAddressReleaseSlot(qemuDomainPCIAddressSetPtr addrs, int slot) ...@@ -931,14 +931,14 @@ int qemuDomainPCIAddressReleaseSlot(qemuDomainPCIAddressSetPtr addrs, int slot)
{ {
virDomainDeviceInfo dev; virDomainDeviceInfo dev;
char *addr; char *addr;
int function;
int ret = 0; int ret = 0;
unsigned int *function = &dev.addr.pci.function;
dev.addr.pci.domain = 0; dev.addr.pci.domain = 0;
dev.addr.pci.bus = 0; dev.addr.pci.bus = 0;
dev.addr.pci.slot = slot; dev.addr.pci.slot = slot;
for (function = 0; function <= QEMU_PCI_ADDRESS_LAST_FUNCTION; function++) { for (*function = 0; *function <= QEMU_PCI_ADDRESS_LAST_FUNCTION; (*function)++) {
addr = qemuPCIAddressAsString(&dev); addr = qemuPCIAddressAsString(&dev);
if (!addr) if (!addr)
return -1; return -1;
...@@ -950,7 +950,7 @@ int qemuDomainPCIAddressReleaseSlot(qemuDomainPCIAddressSetPtr addrs, int slot) ...@@ -950,7 +950,7 @@ int qemuDomainPCIAddressReleaseSlot(qemuDomainPCIAddressSetPtr addrs, int slot)
VIR_FREE(addr); VIR_FREE(addr);
if (qemuDomainPCIAddressReleaseFunction(addrs, slot, function) < 0) if (qemuDomainPCIAddressReleaseFunction(addrs, slot, *function) < 0)
ret = -1; ret = -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册