From: Michael S. Tsirkin Date: Tue, 14 Sep 2010 11:48:17 +0000 (+0200) Subject: vhost: fix infinite loop on error path X-Git-Tag: v0.14.0-rc0~640^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6b37c87c96a5b148685e8e6bf09d0aca953cb1a8;p=thirdparty%2Fqemu.git vhost: fix infinite loop on error path file.index is unsigned, hence 'while (--file.index >= 0)' will loop > forever. Change to while (file.index-- > 0). Reported-by: Jes Sorensen Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/vhost_net.c b/hw/vhost_net.c index 4a7b8194f2c..c068be1f549 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -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); }