hyperv: Add a check for ring_size value
authorHaiyang Zhang <haiyangz@microsoft.com>
Wed, 25 Jul 2012 08:08:41 +0000 (08:08 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 25 Jul 2012 22:31:30 +0000 (15:31 -0700)
It prevents ring_size being set to a too small value.

Reported-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hyperv/netvsc_drv.c

index 8e23c084c4a73e32888eee1310f47690d2f6aca2..8c5a1c43c81d257c09a67385e01da93f3c24465f 100644 (file)
@@ -47,7 +47,7 @@ struct net_device_context {
        struct work_struct work;
 };
 
-
+#define RING_SIZE_MIN 64
 static int ring_size = 128;
 module_param(ring_size, int, S_IRUGO);
 MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
@@ -518,6 +518,11 @@ static void __exit netvsc_drv_exit(void)
 
 static int __init netvsc_drv_init(void)
 {
+       if (ring_size < RING_SIZE_MIN) {
+               ring_size = RING_SIZE_MIN;
+               pr_info("Increased ring_size to %d (min allowed)\n",
+                       ring_size);
+       }
        return vmbus_driver_register(&netvsc_drv);
 }