diff mbox

[2/4] vhost-test: Always access vq->private_data under vq mutex

Message ID 1367909676-11788-3-git-send-email-asias@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Asias He May 7, 2013, 6:54 a.m. UTC
Signed-off-by: Asias He <asias@redhat.com>
---
 drivers/vhost/test.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox

Patch

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);
 }