[prev in list] [next in list] [prev in thread] [next in thread] 

List:       v9fs-developer
Subject:    [V9fs-developer] [PATCH] net/9p: Prevent crash when booting on
From:       "Aneesh Kumar K.V" <aneesh.kumar () linux ! vnet ! ibm ! com>
Date:       2010-02-23 7:31:58
Message-ID: 1266909598-15585-1-git-send-email-aneesh.kumar () linux ! vnet ! ibm ! com
[Download RAW message or body]

This patch use a feature flag to check whether qemu
support specifying mount device using mount_tag config
variable. If not supported we fail the virtio 9p device
probe.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 include/linux/virtio_9p.h |    5 +++++
 net/9p/trans_virtio.c     |   26 +++++++++++++++++++-------
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/include/linux/virtio_9p.h b/include/linux/virtio_9p.h
index e7fb078..5cf1176 100644
--- a/include/linux/virtio_9p.h
+++ b/include/linux/virtio_9p.h
@@ -5,6 +5,11 @@
 #include <linux/virtio_ids.h>
 #include <linux/virtio_config.h>
 
+/* The feature bitmap for virtio 9P */
+
+/* The mount point is specified in a config variable */
+#define VIRTIO_9P_MOUNT_TAG 0
+
 struct virtio_9p_config {
 	/* length of the tag name */
 	__u16 tag_len;
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index a04a7e4..026775a 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -256,8 +256,14 @@ static int p9_virtio_probe(struct virtio_device *vdev)
 	sg_init_table(chan->sg, VIRTQUEUE_NUM);
 
 	chan->inuse = false;
-	vdev->config->get(vdev, offsetof(struct virtio_9p_config, tag_len),
-			&tag_len, sizeof(tag_len));
+	if (virtio_has_feature(vdev, VIRTIO_9P_MOUNT_TAG)) {
+		vdev->config->get(vdev,
+				offsetof(struct virtio_9p_config, tag_len),
+				&tag_len, sizeof(tag_len));
+	} else {
+		err = -EINVAL;
+		goto out_free_vq;
+	}
 	tag = kmalloc(tag_len, GFP_KERNEL);
 	if (!tag) {
 		err = -ENOMEM;
@@ -352,13 +358,19 @@ static struct virtio_device_id id_table[] = {
 	{ 0 },
 };
 
+static unsigned int features[] = {
+	VIRTIO_9P_MOUNT_TAG,
+};
+
 /* The standard "struct lguest_driver": */
 static struct virtio_driver p9_virtio_drv = {
-	.driver.name = 	KBUILD_MODNAME,
-	.driver.owner = THIS_MODULE,
-	.id_table =	id_table,
-	.probe = 	p9_virtio_probe,
-	.remove =	p9_virtio_remove,
+	.feature_table  = features,
+	.feature_table_size = ARRAY_SIZE(features),
+	.driver.name    = KBUILD_MODNAME,
+	.driver.owner	= THIS_MODULE,
+	.id_table	= id_table,
+	.probe		= p9_virtio_probe,
+	.remove		= p9_virtio_remove,
 };
 
 static struct p9_trans_module p9_virtio_trans = {
-- 
1.7.0.83.g241b9


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
V9fs-developer mailing list
V9fs-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/v9fs-developer
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic