Commit 8b9b0927 authored by Sowmini Varadhan's avatar Sowmini Varadhan Committed by Ben Hutchings

sunvnet: clean up objects created in vnet_new() on vnet_exit()

[ Upstream commit a4b70a07 ]

Nothing cleans up the objects created by
vnet_new(), they are completely leaked.

vnet_exit(), after doing the vio_unregister_driver() to clean
up ports, should call a helper function that iterates over vnet_list
and cleans up those objects. This includes unregister_netdevice()
as well as free_netdev().
Signed-off-by: default avatarSowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: default avatarDave Kleikamp <dave.kleikamp@oracle.com>
Reviewed-by: default avatarKarl Volz <karl.volz@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 2a3fda71
...@@ -1089,6 +1089,24 @@ static struct vnet * __devinit vnet_find_or_create(const u64 *local_mac) ...@@ -1089,6 +1089,24 @@ static struct vnet * __devinit vnet_find_or_create(const u64 *local_mac)
return vp; return vp;
} }
static void vnet_cleanup(void)
{
struct vnet *vp;
struct net_device *dev;
mutex_lock(&vnet_list_mutex);
while (!list_empty(&vnet_list)) {
vp = list_first_entry(&vnet_list, struct vnet, list);
list_del(&vp->list);
dev = vp->dev;
/* vio_unregister_driver() should have cleaned up port_list */
BUG_ON(!list_empty(&vp->port_list));
unregister_netdev(dev);
free_netdev(dev);
}
mutex_unlock(&vnet_list_mutex);
}
static const char *local_mac_prop = "local-mac-address"; static const char *local_mac_prop = "local-mac-address";
static struct vnet * __devinit vnet_find_parent(struct mdesc_handle *hp, static struct vnet * __devinit vnet_find_parent(struct mdesc_handle *hp,
...@@ -1249,7 +1267,6 @@ static int vnet_port_remove(struct vio_dev *vdev) ...@@ -1249,7 +1267,6 @@ static int vnet_port_remove(struct vio_dev *vdev)
kfree(port); kfree(port);
unregister_netdev(vp->dev);
} }
return 0; return 0;
} }
...@@ -1280,6 +1297,7 @@ static int __init vnet_init(void) ...@@ -1280,6 +1297,7 @@ static int __init vnet_init(void)
static void __exit vnet_exit(void) static void __exit vnet_exit(void)
{ {
vio_unregister_driver(&vnet_port_driver); vio_unregister_driver(&vnet_port_driver);
vnet_cleanup();
} }
module_init(vnet_init); module_init(vnet_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment