sunvnet: clean up objects created in vnet_new() on vnet_exit()
Subsystems (2)
PATCH v2 1/1 sunvnet: clean up objects created in vnet_new() on vnet_exit()
Nothing cleans up the objects created byvnet_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().
---
v2: incorporated comments from David Miller.
v3: muttrc config tweaks to avoid list-rejection
and set up correct From/Message-ID headers.
drivers/net/ethernet/sun/sunvnet.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/net/ethernet/sun/sunvnet.c +19 -1
@@ -1083,6 +1083,24 @@ static struct vnet *vnet_find_or_create(const u64 *local_mac)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 struct vnet *vnet_find_parent(struct mdesc_handle *hp,
@@ -1240,7 +1258,6 @@ static int vnet_port_remove(struct vio_dev *vdev)kfree (port); -unregister_netdev (vp->dev); }return 0 ; }
@@ -1268,6 +1285,7 @@ static int __init vnet_init(void) static void __exit vnet_exit(void) {vio_unregister_driver (&vnet_port_driver); +vnet_cleanup (); }module_init (vnet_init);
Signature · 1 line
1.8.4.2
David Miller
maintainerFrom: Sowmini Varadhan <[email protected]>
Date: Wed, 16 Jul 2014 10:02:26 -0400
Quoted 9 lines
Nothing cleans up the objects created by
vnet_new(), they are completely leaked.
vnet_exit(), after doing thevio_unregister_driver()to clean up ports, should call a helper function that iterates overvnet_listand cleans up those objects. This includesunregister_netdevice()as well asfree_netdev().
Quoted 8 lines
Signed-off-by Sowmini Varadhan <[email protected]>Acked-by Dave Kleikamp <[email protected]>Reviewed-by Karl Volz <[email protected]>---
v2: incorporated comments from David Miller.
v3: muttrc config tweaks to avoid list-rejection
and set up correct From/Message-ID headers.
Looks great, applied and queued up for -stable, thanks!