Skip to content

Commit

Permalink
net/xen-netfront: only clean up queues if present
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Chas Williams authored and David S. Miller committed Aug 23, 2015
1 parent f5117ce commit 9a873c7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/xen-netfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9a873c7

Please sign in to comment.