]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
qemu: fix infinite loop in OOM error path
authorLaine Stump <laine@laine.org>
Tue, 25 Jun 2013 02:42:35 +0000 (22:42 -0400)
committerLaine Stump <laine@laine.org>
Tue, 25 Jun 2013 22:24:56 +0000 (18:24 -0400)
A loop in qemuPrepareHostdevPCIDevices() intended to cycle through all
the objects on the list pcidevs was doing "while (listcount > 0)", but
nothing in the body of the loop was reducing the size of the list - it
was instead removing items from a *different* list. It has now been
safely changed to a for() loop.

src/qemu/qemu_hostdev.c

index 09ac6ad057fef5048e017bf261eb7149c17eaab7..404939e78ddd917aabd4e06ceff08e62811c0ea1 100644 (file)
@@ -638,8 +638,8 @@ inactivedevs:
     /* Only steal all the devices from driver->activePciHostdevs. We will
      * free them in virObjectUnref().
      */
-    while (virPCIDeviceListCount(pcidevs) > 0) {
-        virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, 0);
+    for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
+        virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
         virPCIDeviceListSteal(driver->activePciHostdevs, dev);
     }