From patchwork Tue May 7 06:54:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 2532241 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 0B614DF215 for ; Tue, 7 May 2013 06:55:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758078Ab3EGGyy (ORCPT ); Tue, 7 May 2013 02:54:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20198 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757107Ab3EGGyw (ORCPT ); Tue, 7 May 2013 02:54:52 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r476snfO018552 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 7 May 2013 02:54:49 -0400 Received: from hj.localdomain.com ([10.66.4.126]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r476sdxY008236; Tue, 7 May 2013 02:54:46 -0400 From: Asias He To: "Michael S. Tsirkin" Cc: Nicholas Bellinger , Rusty Russell , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, target-devel@vger.kernel.org, Asias He Subject: [PATCH 2/4] vhost-test: Always access vq->private_data under vq mutex Date: Tue, 7 May 2013 14:54:34 +0800 Message-Id: <1367909676-11788-3-git-send-email-asias@redhat.com> In-Reply-To: <1367909676-11788-1-git-send-email-asias@redhat.com> References: <1367909676-11788-1-git-send-email-asias@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Asias He --- drivers/vhost/test.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c index dc526eb..435b911 100644 --- a/drivers/vhost/test.c +++ b/drivers/vhost/test.c @@ -48,11 +48,12 @@ static void handle_vq(struct vhost_test *n) size_t len, total_len = 0; void *private; - private = rcu_dereference_check(vq->private_data, 1); - if (!private) - return; mutex_lock(&vq->mutex); + private = vq->private_data; + if (!private) + goto out; + vhost_disable_notify(&n->dev, vq); for (;;) { @@ -89,7 +90,7 @@ static void handle_vq(struct vhost_test *n) break; } } - +out: mutex_unlock(&vq->mutex); }