From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=43650 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvSP6-0001d4-Hh for qemu-devel@nongnu.org; Tue, 14 Sep 2010 06:06:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvSP4-0008AH-Qv for qemu-devel@nongnu.org; Tue, 14 Sep 2010 06:06:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49387) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvSP4-0008AA-KY for qemu-devel@nongnu.org; Tue, 14 Sep 2010 06:06:18 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8EA6Gb9016806 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 Sep 2010 06:06:17 -0400 From: Jes.Sorensen@redhat.com Date: Tue, 14 Sep 2010 12:06:12 +0200 Message-Id: <1284458772-6474-1-git-send-email-Jes.Sorensen@redhat.com> Subject: [Qemu-devel] [PATCH 1/1] Fix loop logic in vhost_net_start()'s error path List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alex.Williamson@redhat.com, mst@redhat.com From: Jes Sorensen file.index is unsigned, hence 'while (--file.index >= 0)' will loop forever. Change it to do {} while (file.index-- > 0) Signed-off-by: Jes Sorensen --- hw/vhost_net.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/vhost_net.c b/hw/vhost_net.c index 4a7b819..b1f8072 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -151,10 +151,10 @@ int vhost_net_start(struct vhost_net *net, return 0; fail: file.fd = -1; - while (--file.index >= 0) { + do { int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file); assert(r >= 0); - } + } while (file.index-- > 0); net->vc->info->poll(net->vc, true); vhost_dev_stop(&net->dev, dev); if (net->dev.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) { -- 1.7.2.2