From patchwork Tue Sep 14 10:06:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 64687 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 89BC7B70A3 for ; Tue, 14 Sep 2010 20:10:13 +1000 (EST) Received: from localhost ([127.0.0.1]:42332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvSQz-0002BU-3g for incoming@patchwork.ozlabs.org; Tue, 14 Sep 2010 06:08:17 -0400 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 Received: from localhost6.localdomain6 ([10.3.113.2]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8EA6ETu003363; Tue, 14 Sep 2010 06:06:15 -0400 From: Jes.Sorensen@redhat.com To: qemu-devel@nongnu.org Date: Tue, 14 Sep 2010 12:06:12 +0200 Message-Id: <1284458772-6474-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Alex.Williamson@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 1/1] Fix loop logic in vhost_net_start()'s error path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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)) {