net/xen-netfront: only clean up queues if present
authorChas Williams <3chas3@gmail.com>
Wed, 19 Aug 2015 23:14:20 +0000 (19:14 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 23 Aug 2015 22:56:12 +0000 (15:56 -0700)
If you simply load and unload the module without starting the interfaces,
the queues are never created and you get a bad pointer dereference.

Signed-off-by: Chas Williams <3chas3@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/xen-netfront.c

index f948c46d51329970c186b2886c267ffba2e807db..002062db2f1dc791b73a1a98c5a4368dfe756179 100644 (file)
@@ -1336,7 +1336,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))
@@ -2101,7 +2101,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;