]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
virtio_net: Fix panic in virtnet_remove
authorKrishna Kumar <krkumar2@in.ibm.com>
Wed, 20 Jul 2011 03:56:02 +0000 (03:56 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 22 Jul 2011 04:29:34 +0000 (21:29 -0700)
Fix a panic in virtnet_remove. unregister_netdev has already
freed up the netdev (and virtnet_info) due to dev->destructor
being set, while virtnet_info is still required. Remove
virtnet_free altogether, and move the freeing of the per-cpu
statistics from virtnet_free to virtnet_remove.

Tested patch below.

Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/virtio_net.c

index fbea637eb742a53459e53878b4a8a0ed42b7813c..0c7321c35ad408ab7ec4ce62383cc2afdf90b541 100644 (file)
@@ -705,14 +705,6 @@ static void virtnet_netpoll(struct net_device *dev)
 }
 #endif
 
-static void virtnet_free(struct net_device *dev)
-{
-       struct virtnet_info *vi = netdev_priv(dev);
-
-       free_percpu(vi->stats);
-       free_netdev(dev);
-}
-
 static int virtnet_open(struct net_device *dev)
 {
        struct virtnet_info *vi = netdev_priv(dev);
@@ -959,7 +951,6 @@ static int virtnet_probe(struct virtio_device *vdev)
        /* Set up network device as normal. */
        dev->netdev_ops = &virtnet_netdev;
        dev->features = NETIF_F_HIGHDMA;
-       dev->destructor = virtnet_free;
 
        SET_ETHTOOL_OPS(dev, &virtnet_ethtool_ops);
        SET_NETDEV_DEV(dev, &vdev->dev);
@@ -1122,6 +1113,7 @@ static void __devexit virtnet_remove(struct virtio_device *vdev)
        while (vi->pages)
                __free_pages(get_a_page(vi, GFP_KERNEL), 0);
 
+       free_percpu(vi->stats);
        free_netdev(vi->dev);
 }