hyperv: Increase the buffer length for netvsc_channel_cb()
[pandora-kernel.git] / drivers / net / hyperv / netvsc.c
index 4ed38ea..5b5644a 100644 (file)
@@ -42,6 +42,12 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
        if (!net_device)
                return NULL;
 
+       net_device->cb_buffer = kzalloc(NETVSC_PACKET_SIZE, GFP_KERNEL);
+       if (!net_device->cb_buffer) {
+               kfree(net_device);
+               return NULL;
+       }
+
        init_waitqueue_head(&net_device->wait_drain);
        net_device->start_remove = false;
        net_device->destroy = false;
@@ -52,6 +58,12 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
        return net_device;
 }
 
+static void free_netvsc_device(struct netvsc_device *nvdev)
+{
+       kfree(nvdev->cb_buffer);
+       kfree(nvdev);
+}
+
 static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
 {
        struct netvsc_device *net_device;
@@ -193,8 +205,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
        }
        if (net_device->send_buf) {
                /* Free up the receive buffer */
-               free_pages((unsigned long)net_device->send_buf,
-                          get_order(net_device->send_buf_size));
+               vfree(net_device->send_buf);
                net_device->send_buf = NULL;
        }
        kfree(net_device->send_section_map);
@@ -303,9 +314,7 @@ static int netvsc_init_buf(struct hv_device *device)
 
        /* Now setup the send buffer.
         */
-       net_device->send_buf =
-               (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
-                                        get_order(net_device->send_buf_size));
+       net_device->send_buf = vzalloc(net_device->send_buf_size);
        if (!net_device->send_buf) {
                netdev_err(ndev, "unable to allocate send "
                           "buffer of size %d\n", net_device->send_buf_size);
@@ -378,8 +387,10 @@ static int netvsc_init_buf(struct hv_device *device)
 
        net_device->send_section_map =
                kzalloc(net_device->map_words * sizeof(ulong), GFP_KERNEL);
-       if (net_device->send_section_map == NULL)
+       if (net_device->send_section_map == NULL) {
+               ret = -ENOMEM;
                goto cleanup;
+       }
 
        goto exit;
 
@@ -552,7 +563,7 @@ int netvsc_device_remove(struct hv_device *device)
        if (net_device->sub_cb_buf)
                vfree(net_device->sub_cb_buf);
 
-       kfree(net_device);
+       free_netvsc_device(net_device);
        return 0;
 }
 
@@ -1094,9 +1105,7 @@ close:
        vmbus_close(device->channel);
 
 cleanup:
-
-       if (net_device)
-               kfree(net_device);
+       free_netvsc_device(net_device);
 
        return ret;
 }