diff options
author | Sowmini Varadhan <sowmini.varadhan@oracle.com> | 2014-07-16 10:02:26 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-17 01:44:07 -0400 |
commit | a4b70a07ed12a71131cab7adce2ce91c71b37060 (patch) | |
tree | 24ac5cfb9dc7db82254914b4f27e581be4a09b35 /drivers/net | |
parent | 7a9810e7bd99c922d9cedf64dbaa5ef6be412295 (diff) |
sunvnet: clean up objects created in vnet_new() on vnet_exit()
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: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Reviewed-by: Karl Volz <karl.volz@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/sun/sunvnet.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c index 1c24a8f368bd..fd411d6e19a2 100644 --- a/drivers/net/ethernet/sun/sunvnet.c +++ b/drivers/net/ethernet/sun/sunvnet.c | |||
@@ -1083,6 +1083,24 @@ static struct vnet *vnet_find_or_create(const u64 *local_mac) | |||
1083 | return vp; | 1083 | return vp; |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | static void vnet_cleanup(void) | ||
1087 | { | ||
1088 | struct vnet *vp; | ||
1089 | struct net_device *dev; | ||
1090 | |||
1091 | mutex_lock(&vnet_list_mutex); | ||
1092 | while (!list_empty(&vnet_list)) { | ||
1093 | vp = list_first_entry(&vnet_list, struct vnet, list); | ||
1094 | list_del(&vp->list); | ||
1095 | dev = vp->dev; | ||
1096 | /* vio_unregister_driver() should have cleaned up port_list */ | ||
1097 | BUG_ON(!list_empty(&vp->port_list)); | ||
1098 | unregister_netdev(dev); | ||
1099 | free_netdev(dev); | ||
1100 | } | ||
1101 | mutex_unlock(&vnet_list_mutex); | ||
1102 | } | ||
1103 | |||
1086 | static const char *local_mac_prop = "local-mac-address"; | 1104 | static const char *local_mac_prop = "local-mac-address"; |
1087 | 1105 | ||
1088 | static struct vnet *vnet_find_parent(struct mdesc_handle *hp, | 1106 | static struct vnet *vnet_find_parent(struct mdesc_handle *hp, |
@@ -1240,7 +1258,6 @@ static int vnet_port_remove(struct vio_dev *vdev) | |||
1240 | 1258 | ||
1241 | kfree(port); | 1259 | kfree(port); |
1242 | 1260 | ||
1243 | unregister_netdev(vp->dev); | ||
1244 | } | 1261 | } |
1245 | return 0; | 1262 | return 0; |
1246 | } | 1263 | } |
@@ -1268,6 +1285,7 @@ static int __init vnet_init(void) | |||
1268 | static void __exit vnet_exit(void) | 1285 | static void __exit vnet_exit(void) |
1269 | { | 1286 | { |
1270 | vio_unregister_driver(&vnet_port_driver); | 1287 | vio_unregister_driver(&vnet_port_driver); |
1288 | vnet_cleanup(); | ||
1271 | } | 1289 | } |
1272 | 1290 | ||
1273 | module_init(vnet_init); | 1291 | module_init(vnet_init); |