]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Fix use of uninitialized memory when releasing PCI slots
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 30 Jun 2011 14:01:54 +0000 (15:01 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 30 Jun 2011 17:04:01 +0000 (18:04 +0100)
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

src/qemu/qemu_command.c

index 7ac1faf9f5d2f2a22d9f125f4024b9373e27a534..90a6653d6f5b08e21af72ea8eaa863bf76333037 100644 (file)
@@ -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;
     }