]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_hostdev: Resolve Coverity issue
authorJohn Ferlan <jferlan@redhat.com>
Thu, 11 Jul 2013 14:42:30 +0000 (10:42 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 11 Jul 2013 18:18:12 +0000 (14:18 -0400)
Recent changes uncovered a possibility that 'last_processed_hostdev_vf'
was set to -1 in 'qemuPrepareHostdevPCIDevices' and would cause problems
in for loop end condition in the 'resetvfnetconfig' label if the
variable was never set to 'i' due to 'qemuDomainHostdevNetConfigReplace'
failure.

src/qemu/qemu_hostdev.c

index 9bdace1a162e3ac3859fe99283a1d4c4cefb3f26..f24d4661e1436a13773eedc57e4158b82f1ce947 100644 (file)
@@ -644,7 +644,8 @@ inactivedevs:
     }
 
 resetvfnetconfig:
-    for (i = 0; i < last_processed_hostdev_vf; i++) {
+    for (i = 0; last_processed_hostdev_vf != -1 &&
+                i < last_processed_hostdev_vf; i++) {
          virDomainHostdevDefPtr hostdev = hostdevs[i];
          if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET &&
              hostdev->parent.data.net) {