aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrishna Kumar <krkumar2@in.ibm.com>2011-07-19 23:56:02 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-22 00:29:34 -0400
commit2e66f55b3afa290337a47e6ea134ac071c5dd9a7 (patch)
tree8955f5e6c3502174768de8c51d480a0abbf51a40
parent87c48fa3b4630905f98268dde838ee43626a060c (diff)
virtio_net: Fix panic in virtnet_remove
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>
-rw-r--r--drivers/net/virtio_net.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index fbea637eb742..0c7321c35ad4 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -705,14 +705,6 @@ static void virtnet_netpoll(struct net_device *dev)
705} 705}
706#endif 706#endif
707 707
708static void virtnet_free(struct net_device *dev)
709{
710 struct virtnet_info *vi = netdev_priv(dev);
711
712 free_percpu(vi->stats);
713 free_netdev(dev);
714}
715
716static int virtnet_open(struct net_device *dev) 708static int virtnet_open(struct net_device *dev)
717{ 709{
718 struct virtnet_info *vi = netdev_priv(dev); 710 struct virtnet_info *vi = netdev_priv(dev);
@@ -959,7 +951,6 @@ static int virtnet_probe(struct virtio_device *vdev)
959 /* Set up network device as normal. */ 951 /* Set up network device as normal. */
960 dev->netdev_ops = &virtnet_netdev; 952 dev->netdev_ops = &virtnet_netdev;
961 dev->features = NETIF_F_HIGHDMA; 953 dev->features = NETIF_F_HIGHDMA;
962 dev->destructor = virtnet_free;
963 954
964 SET_ETHTOOL_OPS(dev, &virtnet_ethtool_ops); 955 SET_ETHTOOL_OPS(dev, &virtnet_ethtool_ops);
965 SET_NETDEV_DEV(dev, &vdev->dev); 956 SET_NETDEV_DEV(dev, &vdev->dev);
@@ -1122,6 +1113,7 @@ static void __devexit virtnet_remove(struct virtio_device *vdev)
1122 while (vi->pages) 1113 while (vi->pages)
1123 __free_pages(get_a_page(vi, GFP_KERNEL), 0); 1114 __free_pages(get_a_page(vi, GFP_KERNEL), 0);
1124 1115
1116 free_percpu(vi->stats);
1125 free_netdev(vi->dev); 1117 free_netdev(vi->dev);
1126} 1118}
1127 1119