aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2011-06-30 15:01:54 +0100
committerDaniel P. Berrange <berrange@redhat.com>2011-06-30 18:04:01 +0100
commit56a77b4920e2a1e027be9f133fab469599864bc9 (patch)
tree4119e010a3163f3c6dddddf6d49932693c384893
parentFix leak of virStreamPtr object with callback added in fdstream impl (diff)
downloadlibvirt-56a77b4920e2a1e027be9f133fab469599864bc9.tar.gz
libvirt-56a77b4920e2a1e027be9f133fab469599864bc9.tar.bz2
libvirt-56a77b4920e2a1e027be9f133fab469599864bc9.zip
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
-rw-r--r--src/qemu/qemu_command.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7ac1faf9f..90a6653d6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -931,14 +931,14 @@ int qemuDomainPCIAddressReleaseSlot(qemuDomainPCIAddressSetPtr addrs, int slot)
{
virDomainDeviceInfo dev;
char *addr;
- int function;
int ret = 0;
+ unsigned int *function = &dev.addr.pci.function;
dev.addr.pci.domain = 0;
dev.addr.pci.bus = 0;
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);
if (!addr)
return -1;
@@ -950,7 +950,7 @@ int qemuDomainPCIAddressReleaseSlot(qemuDomainPCIAddressSetPtr addrs, int slot)
VIR_FREE(addr);
- if (qemuDomainPCIAddressReleaseFunction(addrs, slot, function) < 0)
+ if (qemuDomainPCIAddressReleaseFunction(addrs, slot, *function) < 0)
ret = -1;
}