Merge tag 'for-linus-4.3-rc0b-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / drivers / net / xen-netfront.c
index 47f791e..f821a97 100644 (file)
@@ -1338,7 +1338,7 @@ static void xennet_disconnect_backend(struct netfront_info *info)
 
        netif_carrier_off(info->netdev);
 
-       for (i = 0; i < num_queues; ++i) {
+       for (i = 0; i < num_queues && info->queues; ++i) {
                struct netfront_queue *queue = &info->queues[i];
 
                if (queue->tx_irq && (queue->tx_irq == queue->rx_irq))
@@ -1350,7 +1350,8 @@ static void xennet_disconnect_backend(struct netfront_info *info)
                queue->tx_evtchn = queue->rx_evtchn = 0;
                queue->tx_irq = queue->rx_irq = 0;
 
-               napi_synchronize(&queue->napi);
+               if (netif_running(info->netdev))
+                       napi_synchronize(&queue->napi);
 
                xennet_release_tx_bufs(queue);
                xennet_release_rx_bufs(queue);
@@ -2103,7 +2104,8 @@ static int xennet_remove(struct xenbus_device *dev)
 
        unregister_netdev(info->netdev);
 
-       xennet_destroy_queues(info);
+       if (info->queues)
+               xennet_destroy_queues(info);
        xennet_free_netdev(info->netdev);
 
        return 0;
@@ -2132,8 +2134,11 @@ static int __init netif_init(void)
 
        pr_info("Initialising Xen virtual ethernet driver\n");
 
-       /* Allow as many queues as there are CPUs, by default */
-       xennet_max_queues = num_online_cpus();
+       /* Allow as many queues as there are CPUs if user has not
+        * specified a value.
+        */
+       if (xennet_max_queues == 0)
+               xennet_max_queues = num_online_cpus();
 
        return xenbus_register_frontend(&netfront_driver);
 }