From patchwork Tue May 3 15:37:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 750452 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p43Fbs9b025118 for ; Tue, 3 May 2011 15:37:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751256Ab1ECPhv (ORCPT ); Tue, 3 May 2011 11:37:51 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:55255 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750725Ab1ECPhv (ORCPT ); Tue, 3 May 2011 11:37:51 -0400 Received: by wwa36 with SMTP id 36so221478wwa.1 for ; Tue, 03 May 2011 08:37:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=mDXm6hmU5SSnY9Y+eax8pk7m675R5LCLNTB0WFni2Ng=; b=GZ32h83zDvgt6P/04GyrDKAi4ckQ33IX6cTqgM4jpCsn0ZqO5Ul3t7+Vh7WT/+5rwJ 1exEzjX8lvStW0LXVo4kWUH2Y0f3m7oJB2BD28znajJOgjwYMKBzZ0eHiHdkCiQA2gXw qtSZ7/2B19p9zzdGf4UM4UAkZcoYVj0r/xTGU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=sFudm0u6HU7lBhR+2pInlz9X0LhZmqda8BQM2XtpTl0obVD4f3/c8LmAiJPxL2UMCq bsiPQH13xtByBnVZNrBXft3yhi6OtfBNWfnwS+OaUulMUW2smNwJarzpn4ht7qpJuQB7 SazM9lZAO+xzdCrCVowZo2Ln62VbVutZl/BE8= Received: by 10.216.136.67 with SMTP id v45mr3797679wei.106.1304437069881; Tue, 03 May 2011 08:37:49 -0700 (PDT) Received: from localhost.localdomain (bzq-79-179-202-103.red.bezeqint.net [79.179.202.103]) by mx.google.com with ESMTPS id o23sm130765wbc.27.2011.05.03.08.37.47 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 May 2011 08:37:49 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, kvm@vger.kernel.org, Sasha Levin Subject: [PATCH 1/2] kvm tools: Fix virt_queue__set_used_elem Date: Tue, 3 May 2011 18:37:37 +0300 Message-Id: <1304437058-15651-1-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 03 May 2011 15:37:54 +0000 (UTC) Increase idx only after updating the used element. Not doing so may mark a buffer as used without having it's head and length updated. Signed-off-by: Sasha Levin --- tools/kvm/virtio.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/tools/kvm/virtio.c b/tools/kvm/virtio.c index 6249521..b2d2407 100644 --- a/tools/kvm/virtio.c +++ b/tools/kvm/virtio.c @@ -7,9 +7,10 @@ struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, uint32_t head, uint32_t len) { struct vring_used_elem *used_elem; - used_elem = &queue->vring.used->ring[queue->vring.used->idx++ % queue->vring.num]; + used_elem = &queue->vring.used->ring[queue->vring.used->idx % queue->vring.num]; used_elem->id = head; used_elem->len = len; + queue->vring.used->idx++; return used_elem; }