hv_netvsc: Allocate the recv_buf buffers after NVSP_MSG1_TYPE_SEND_RECV_BUF
[linux-2.6-microblaze.git] / drivers / net / hyperv / netvsc.c
index 0fba825..9db1ea3 100644 (file)
@@ -311,7 +311,7 @@ static int netvsc_init_buf(struct hv_device *device,
        struct nvsp_message *init_packet;
        unsigned int buf_size;
        size_t map_words;
-       int ret = 0;
+       int i, ret = 0;
 
        /* Get receive buffer area. */
        buf_size = device_info->recv_sections * device_info->recv_section_size;
@@ -405,6 +405,16 @@ static int netvsc_init_buf(struct hv_device *device,
                goto cleanup;
        }
 
+       for (i = 0; i < VRSS_CHANNEL_MAX; i++) {
+               struct netvsc_channel *nvchan = &net_device->chan_table[i];
+
+               nvchan->recv_buf = kzalloc(net_device->recv_section_size, GFP_KERNEL);
+               if (nvchan->recv_buf == NULL) {
+                       ret = -ENOMEM;
+                       goto cleanup;
+               }
+       }
+
        /* Setup receive completion ring.
         * Add 1 to the recv_section_cnt because at least one entry in a
         * ring buffer has to be empty.
@@ -1549,12 +1559,6 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
        for (i = 0; i < VRSS_CHANNEL_MAX; i++) {
                struct netvsc_channel *nvchan = &net_device->chan_table[i];
 
-               nvchan->recv_buf = kzalloc(device_info->recv_section_size, GFP_KERNEL);
-               if (nvchan->recv_buf == NULL) {
-                       ret = -ENOMEM;
-                       goto cleanup2;
-               }
-
                nvchan->channel = device->channel;
                nvchan->net_device = net_device;
                u64_stats_init(&nvchan->tx_stats.syncp);