]> git.proxmox.com Git - qemu.git/commitdiff
vhost: fix infinite loop on error path
authorMichael S. Tsirkin <mst@redhat.com>
Tue, 14 Sep 2010 11:48:17 +0000 (13:48 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 14 Sep 2010 14:02:23 +0000 (16:02 +0200)
file.index is unsigned, hence 'while (--file.index >= 0)'
will loop > forever. Change to while (file.index-- > 0).

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/vhost_net.c

index 4a7b8194f2cdb67d43c22aeb2d900d56d01c6a45..c068be1f54944c26c61d0283a7553da7aae224da 100644 (file)
@@ -151,7 +151,7 @@ int vhost_net_start(struct vhost_net *net,
     return 0;
 fail:
     file.fd = -1;
-    while (--file.index >= 0) {
+    while (file.index-- > 0) {
         int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file);
         assert(r >= 0);
     }